LinuxTV Patchwork media: usbvision: fix a potential NULL pointer dereference

login
register
mail settings
Submitter Kangjie Lu
Date March 9, 2019, 7:42 a.m.
Message ID <20190309074228.5723-1-kjlu@umn.edu>
Download mbox | patch
Permalink /patch/54983/
State New
Delegated to: Hans Verkuil
Headers show

Comments

Kangjie Lu - March 9, 2019, 7:42 a.m.
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>
---
 drivers/media/usb/usbvision/usbvision-core.c | 3 +++
 1 file changed, 3 insertions(+)
Kangjie Lu - March 23, 2019, 3:07 a.m.
> On Mar 9, 2019, at 1:42 AM, Kangjie Lu <kjlu@umn.edu> wrote:
> 
> 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>
> ---
> drivers/media/usb/usbvision/usbvision-core.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c
> index 31e0e98d6daf..1b0d0a0f0e87 100644
> --- a/drivers/media/usb/usbvision/usbvision-core.c
> +++ b/drivers/media/usb/usbvision/usbvision-core.c
> @@ -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;
> +

Can someone review this patch?

> 		urb->dev = dev;
> 		urb->context = usbvision;
> 		urb->pipe = usb_rcvisocpipe(dev, usbvision->video_endp);
> -- 
> 2.17.1
>

Patch

diff --git a/drivers/media/usb/usbvision/usbvision-core.c b/drivers/media/usb/usbvision/usbvision-core.c
index 31e0e98d6daf..1b0d0a0f0e87 100644
--- a/drivers/media/usb/usbvision/usbvision-core.c
+++ b/drivers/media/usb/usbvision/usbvision-core.c
@@ -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);

Privacy Policy