From 3e1e9fa4564d65a84776ff65aa2f2fa340d27be7 Mon Sep 17 00:00:00 2001 From: a17671 Date: Thu, 6 Dec 2018 14:07:39 +0800 Subject: [PATCH] usb:xhci-hub:Fix Null pointer panic System panic at xhci_hub_check_speed+0x44/0x74 After disconnect the otg device from host Add the null pointer check to fix the problem panic trace: [ 394.979815,2] xhci-hcd xhci-hcd.2.auto: USB bus 2 deregistered [ 394.980005,2] xhci-hcd xhci-hcd.2.auto: remove, state 4 [ 394.980100,2] usb usb1: USB disconnect, device number 1 [ 394.954183,0] Unable to handle kernel read from unreadable memory at virtual address 0000001c [ 395.067339,0] task: ffffffc876ef4400 task.stack: ffffff800b328000 [ 395.073424,0] PC is at xhci_hub_check_speed+0x44/0x74 [ 395.078455,0] LR is at xhci_hub_check_speed+0x14/0x74 [ 395.094516,0] x29: ffffff800b32ba70 x28: 0000000000000000 [ 395.099986,0] x27: ffffff800b32bc08 x26: 00000000ffffffff [ 395.105453,0] x25: 0000000000000001 x24: 0000000000000001 [ 395.110924,0] x23: ffffffc84a14a140 x22: ffffffc835343800 [ 395.116393,0] x21: 0000000000000000 x20: ffffffc84a14a000 [ 395.121866,0] x19: ffffffc053b5c000 x18: 0000000000000001 [ 395.127336,0] x17: 0000000000000000 x16: 0000000000000000 [ 395.132844,0] x15: ffffff8009567000 x14: 0000000000000001 [ 395.138275,0] x13: 0000000000258024 x12: 000000000000cf90 [ 395.143745,0] x11: f6e18e3f25207900 x10: 0000000000000000 [ 395.149216,0] x9 : ffffffc84a14a458 x8 : 0000000000000001 [ 395.154688,0] x7 : 0000000000000000 x6 : ffffff80099394e6 [ 395.160160,0] x5 : 0000000000000033 x4 : 0000000000000000 [ 395.165627,0] x3 : ffffff800b32b968 x2 : ffffff8008090470 [ 395.171097,0] x1 : ffffff800b32b968 x0 : 0000000000000000 [ 396.318730,0] [] xhci_hub_check_speed+0x44/0x74 [ 396.324803,0] [] hcd_bus_suspend+0x144/0x24c [ 396.330617,0] [] generic_suspend+0x44/0x4c [ 396.336262,0] [] usb_suspend_both+0x164/0x234 [ 396.342165,0] [] usb_runtime_suspend+0x30/0x68 [ 396.348159,0] [] __rpm_callback+0xc4/0x1cc [ 396.353800,0] [] rpm_callback+0x28/0x7c [ 396.359181,0] [] rpm_suspend+0x210/0x4dc [ 396.364652,0] [] __pm_runtime_suspend+0x80/0xa4 [ 396.370731,0] [] usb_runtime_idle+0x28/0x38 [ 396.376461,0] [] __rpm_callback+0xc4/0x1cc [ 396.382105,0] [] rpm_idle+0x200/0x350 [ 396.387314,0] [] pm_runtime_work+0x5c/0x90 [ 396.392961,0] [] process_one_work+0x1dc/0x408 [ 396.398863,0] [] worker_thread+0x220/0x340 [ 396.404510,0] [] kthread+0x11c/0x12c [ 396.409632,0] [] ret_from_fork+0x10/0x18 Change-Id: I4bf5584143b8434ff5a99c7c9855bf74616da39f Signed-off-by: a17671 Reviewed-on: https://gerrit.mot.com/1279212 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/usb/host/xhci-hub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index fc33c542e847..9e19b25291eb 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1509,6 +1509,8 @@ int xhci_hub_check_speed(struct usb_hcd *hcd) for (i = 0; i < MAX_HC_SLOTS; i++) { if (!xhci->devs[i]) continue; + if (!xhci->devs[i]->udev) + continue; speed = xhci->devs[i]->udev->speed; if (speed >= USB_SPEED_SUPER) { return 1; -- 2.20.1