Skip to content

Commit d471d71

Browse files
wuliangfengrkhuangtao
authored andcommitted
usb: gadget: uvc: fix NULL pointer dereference when usb hotplug
When do uvc hotplug test on RV1126 EVB, it may crash in the uvc_v4l2_streamon() with the following error log. Because it tries to enable the video stream after usb disconnect. [ 1748.947755] configfs-gadget gadget: uvc_function_disable [ 1748.947947] android_work: sent uevent USB_STATE=DISCONNECTED [ 1748.955347] Unable to handle kernel NULL pointer dereference at virtual address 00000003 [ 1748.956158] pgd = ef2a7e72 [ 1748.956550] [00000003] *pgd=6dde7835 [ 1748.956893] Internal error: Oops: 17 [#1] PREEMPT SMP ARM [ 1748.957381] Modules linked in: galcore(O) bcmdhd [ 1748.957819] CPU: 3 PID: 2706 Comm: uvc_gadget_pthr Tainted: G W O 4.19.111 #9 [ 1748.958567] Hardware name: Generic DT based system [ 1748.959218] PC is at uvcg_video_enable+0xb8/0x228 [ 1748.959775] LR is at vb2_core_streamon+0x11c/0x15c ...... [ 1749.041063] [<b056a2cc>] (uvcg_video_enable) from [<b0569968>] (uvc_v4l2_streamon+0x28/0x70) [ 1749.041906] [<b0569968>] (uvc_v4l2_streamon) from [<b0590b54>] (__video_do_ioctl+0x1c8/0x3a0) [ 1749.042681] [<b0590b54>] (__video_do_ioctl) from [<b0594288>] (video_usercopy+0x200/0x494) [ 1749.043475] [<b0594288>] (video_usercopy) from [<b0220c38>] (do_vfs_ioctl+0xac/0x798) [ 1749.044178] [<b0220c38>] (do_vfs_ioctl) from [<b0221358>] (ksys_ioctl+0x34/0x58) [ 1749.044843] [<b0221358>] (ksys_ioctl) from [<b0101000>] (ret_fast_syscall+0x0/0x4c) Signed-off-by: William Wu <william.wu@rock-chips.com> Change-Id: I6bb58133aaade0ff389fa4af2cfc05fe598de250
1 parent 886ed64 commit d471d71

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/usb/gadget/function/uvc_v4l2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ uvc_v4l2_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
198198
if (type != video->queue.queue.type)
199199
return -EINVAL;
200200

201+
if (uvc->state != UVC_STATE_CONNECTED)
202+
return -ENODEV;
203+
201204
/* Enable UVC video. */
202205
ret = uvcg_video_enable(video, 1);
203206
if (ret < 0)

0 commit comments

Comments
 (0)