linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xhci-mtk: Fix NULL pointer dereference with xhci_irq() for shared_hcd
@ 2020-01-17  7:41 Macpaul Lin
  2020-01-31 14:50 ` Mathias Nyman
  2020-02-02 19:29 ` Guenter Roeck
  0 siblings, 2 replies; 10+ messages in thread
From: Macpaul Lin @ 2020-01-17  7:41 UTC (permalink / raw)
  To: Mathias Nyman, Greg Kroah-Hartman, Matthias Brugger, linux-usb,
	linux-arm-kernel, linux-mediatek, linux-kernel, Chunfeng Yun
  Cc: Mediatek WSD Upstream, Macpaul Lin, Sriharsha Allenki

According to NULL pointer fix: https://tinyurl.com/uqft5ra
xhci: Fix NULL pointer dereference with xhci_irq() for shared_hcd
The similar issue has also been found in QC activities in Mediatek.

Here quote the description from the referenced patch as follows.
"Commit ("f068090426ea xhci: Fix leaking USB3 shared_hcd
at xhci removal") sets xhci_shared_hcd to NULL without
stopping xhci host. This results into a race condition
where shared_hcd (super speed roothub) related interrupts
are being handled with xhci_irq happens when the
xhci_plat_remove is called and shared_hcd is set to NULL.
Fix this by setting the shared_hcd to NULL only after the
controller is halted and no interrupts are generated."

Signed-off-by: Sriharsha Allenki <sallenki@codeaurora.org>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
---
 drivers/usb/host/xhci-mtk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index b18a6baef204..c227c67f5dc5 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -593,11 +593,11 @@ static int xhci_mtk_remove(struct platform_device *dev)
 	struct usb_hcd  *shared_hcd = xhci->shared_hcd;
 
 	usb_remove_hcd(shared_hcd);
-	xhci->shared_hcd = NULL;
 	device_init_wakeup(&dev->dev, false);
 
 	usb_remove_hcd(hcd);
 	usb_put_hcd(shared_hcd);
+	xhci->shared_hcd = NULL;
 	usb_put_hcd(hcd);
 	xhci_mtk_sch_exit(mtk);
 	xhci_mtk_clks_disable(mtk);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-03-06  2:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17  7:41 [PATCH] xhci-mtk: Fix NULL pointer dereference with xhci_irq() for shared_hcd Macpaul Lin
2020-01-31 14:50 ` Mathias Nyman
2020-02-01 11:20   ` Macpaul Lin
2020-02-04  9:44     ` Mathias Nyman
2020-03-04  3:16       ` Macpaul Lin
2020-03-04 14:39         ` Mathias Nyman
2020-03-05  2:58           ` Macpaul Lin
2020-03-05 18:32             ` Greg Kroah-Hartman
2020-03-06  2:36               ` Macpaul Lin
2020-02-02 19:29 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).