media: usbvision: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Sat, 9 Mar 2019 07:42:26 +0000 (02:42 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 29 Mar 2019 11:42:56 +0000 (07:42 -0400)
In case usb_alloc_coherent fails, the fix returns -ENOMEM to
avoid a potential NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/usb/usbvision/usbvision-core.c

index 92d166bf8c122ec315a99b4c86bdc1c75b432de0..abc4eed832a31982f1db07ebdccaa4a48694eafb 100644 (file)
@@ -2302,6 +2302,9 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision)
                                           sb_size,
                                           GFP_KERNEL,
                                           &urb->transfer_dma);
+               if (!usbvision->sbuf[buf_idx].data)
+                       return -ENOMEM;
+
                urb->dev = dev;
                urb->context = usbvision;
                urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);