OSDN Git Service

usb: xhci-mtk: fix oops when unbind driver
authorChunfeng Yun <chunfeng.yun@mediatek.com>
Wed, 31 Mar 2021 08:25:42 +0000 (16:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Apr 2021 13:56:33 +0000 (15:56 +0200)
commitf351f4b63dac127079bbd77da64b2a61c09d522d
tree1c5be07595660397e627f24dcf80896654416562
parentd8fca036ef6d5c7e93157edeab614c8cd2758e90
usb: xhci-mtk: fix oops when unbind driver

The oops happens when unbind driver through sysfs as following,
because xhci_mtk_drop_ep() try to drop the endpoint of root hub
which is not added by xhci_add_endpoint() and the virtual device
is not allocated, in fact also needn't drop it, so should skip it.

Call trace:
 xhci_mtk_drop_ep+0x1b8/0x298
 usb_hcd_alloc_bandwidth+0x1d8/0x380
 usb_disable_device_endpoints+0x8c/0xe0
 usb_disable_device+0x128/0x168
 usb_disconnect+0xbc/0x2c8
 usb_remove_hcd+0xd8/0x210
 xhci_mtk_remove+0x98/0x108
 platform_remove+0x28/0x60
 device_release_driver_internal+0x110/0x1e8
 device_driver_detach+0x18/0x28
 unbind_store+0xd4/0x108
 drv_attr_store+0x24/0x38

Fixes: 14295a150050 ("usb: xhci-mtk: support to build xhci-mtk-hcd.ko")
Reported-by: Eddie Hung <eddie.hung@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1617179142-2681-2-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mtk-sch.c