Skip to content

Commit 57fda07

Browse files
wuliangfenggoenjoy-hlm
authored andcommitted
usb: dwc3: gadget: fix NULL pointer dereference in dwc3_wIndex_to_dep
This patch fixes the kernel panic issue when do reboot test on RV1126 USB AI Camera Board with the following error log: [3.818529] android_work: did not send uevent (0 0 (null)) [3.890319] android_work: sent uevent USB_STATE=CONNECTED [3.929523] configfs-gadget gadget: high-speed config #1: b [3.929743] configfs-gadget gadget: uvc_function_set_alt(2, 0) [3.929771] configfs-gadget gadget: reset UVC Control [3.929806] configfs-gadget gadget: uvc_function_set_alt(3, 0) [3.930243] android_work: sent uevent USB_STATE=CONFIGURED [3.931423] dwc3 ffd00000.dwc3: unexpected direction for Data Phase [3.931543] Unable to handle kernel NULL pointer dereference at virtual address 0000005c [3.933344] pgd = 6319bbbb [3.933600] [0000005c] *pgd=00000000 [3.933941] Internal error: Oops: 17 [#1] PREEMPT SMP ARM [3.934433] Modules linked in: galcore(O) [3.934832] CPU: 0 PID: 568 Comm: irq/61-dwc3 Tainted: G O 4.19.111 #9 [3.935523] Hardware name: Generic DT based system [3.935974] PC is at dwc3_ep0_interrupt+0x638/0x80c [3.936417] LR is at dwc3_thread_interrupt+0x7d4/0xbfc [3.936897] pc : [<b0521224>] lr : [<b051ea4c>] psr: 600d00d3 [3.937462] sp : e607fe88 ip : 00000003 fp : e837d040 [3.937925] r10: e830e640 r9 : 00000008 r8 : e8302900 [3.938386] r7 : 00000000 r6 : e607ff08 r5 : e837d040 r4 : b0c08c48 [3.938965] r3 : 00000050 r2 : 00000000 r1 : e9042000 r0 : 00000004 [3.939546] Flags: nZCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment user [3.940213] Control: 10c5387d Table: 3671c06a DAC: 00000055 ... [4.013246] [<b0521224>] (dwc3_ep0_interrupt) from [<b051ea4c>] (dwc3_thread_interrupt+0x7d4/0xbfc) [4.014059] [<b051ea4c>] (dwc3_thread_interrupt) from [<b016ded0>] (irq_thread_fn+0x1c/0x7c) [4.014835] [<b016ded0>] (irq_thread_fn) from [<b016e1d4>] (irq_thread+0x124/0x200) [4.015520] [<b016e1d4>] (irq_thread) from [<b014290c>] (kthread+0x140/0x170) [4.016175] [<b014290c>] (kthread) from [<b01010d8>] (ret_from_fork+0x14/0x3c) [4.016831] Exception stack(0xe607ffb0 to 0xe607fff8) Change-Id: I4191444b527eb03a5283f662b1ad4c9d9c08cd19 Signed-off-by: William Wu <[email protected]>
1 parent 89d4907 commit 57fda07

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/usb/dwc3/ep0.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le)
292292
epnum |= 1;
293293

294294
dep = dwc->eps[epnum];
295+
if (!dep) {
296+
dev_warn(dwc->dev, "epnum %d, windex 0x%08x\n", epnum, windex);
297+
return NULL;
298+
}
299+
295300
if (dep->flags & DWC3_EP_ENABLED)
296301
return dep;
297302

0 commit comments

Comments
 (0)