sound: usb: usx2y: is it a null pointer deference in function usX2Y_rate_set?
Hi, all: when reviewing function usX2Y_rate_set, here may exist a NULL pointer deference if kmalloc_array failed or usb_alloc_urb failed, in cleanup, we should judge whether us->urb[i] is NULL first. static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) { us = kzalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL); if (NULL == us) { err = -ENOMEM; goto cleanup; } usbdata = kmalloc_array(NOOF_SETRATE_URBS, sizeof(int), GFP_KERNEL); if (NULL == usbdata) { err = -ENOMEM; goto cleanup; } for (i = 0; i < NOOF_SETRATE_URBS; ++i) { if (NULL == (us->urb[i] = usb_alloc_urb(0, GFP_KERNEL))) { err = -ENOMEM; goto cleanup; } ... } ... cleanup: if (us) { us->submitted = 2*NOOF_SETRATE_URBS; for (i = 0; i < NOOF_SETRATE_URBS; ++i) { struct urb *urb = us->urb[i]; if (urb->status) { if (!err) err = -ENODEV; usb_kill_urb(urb); } usb_free_urb(urb);
On Mon, 20 Apr 2020 09:22:11 +0200, 亿一 wrote:
Hi, all: when reviewing function usX2Y_rate_set, here may exist a NULL pointer deference if kmalloc_array failed or usb_alloc_urb failed, in cleanup, we should judge whether us->urb[i] is NULL first.
Right, that's a missing check. Would you submit the fix patch, or shall I write quickly?
thanks,
Takashi
you can patch it and add a Reported by Lin Yi teroincn@gmail.com if pleasure.~
thanks,
Lin Yi
Takashi Iwai tiwai@suse.de 于2020年4月20日周一 下午3:34写道:
On Mon, 20 Apr 2020 09:22:11 +0200, 亿一 wrote:
Hi, all: when reviewing function usX2Y_rate_set, here may exist a NULL pointer deference if kmalloc_array failed or usb_alloc_urb failed, in cleanup, we should judge whether us->urb[i] is NULL first.
Right, that's a missing check. Would you submit the fix patch, or shall I write quickly?
thanks,
Takashi
participants (2)
-
Takashi Iwai
-
亿一