DORMANTno replies

[PATCH] usb: host: tegra: fix potential NULL pointer dereference

From: Wei Yongjun <hidden>
Date: 2012-11-01 06:57:38
Subsystem: the rest, usb ehci driver, usb subsystem · Maintainers: Linus Torvalds, Alan Stern, Greg Kroah-Hartman

From: Wei Yongjun <redacted>

The dereference should be moved below the NULL test.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <redacted>
---
 drivers/usb/host/ehci-tegra.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 6223d17..e40fcb0 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -776,9 +776,13 @@ fail_clk:
 static int tegra_ehci_remove(struct platform_device *pdev)
 {
 	struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
+	struct usb_hcd *hcd;
+
+	if (tegra == NULL)
+		return -EINVAL;
 
-	if (tegra == NULL || hcd == NULL)
+	hcd = ehci_to_hcd(tegra->ehci);
+	if (hcd == NULL)
 		return -EINVAL;
 
 	pm_runtime_get_sync(&pdev->dev);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help