[PATCH 1/1] usb: host: ehci-spear: Fix potential NULL pointer dereferencing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



'hcd' is dereferenced before NULL check. Move the assignment after
the check to avoid potential NULL pointer dereferencing error.

Signed-off-by: Sachin Kamat <sachin.kamat@xxxxxxxxxx>
Cc: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
 drivers/usb/host/ehci-spear.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index f5ac4e2..326bfea 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -146,10 +146,13 @@ fail:
 static int spear_ehci_hcd_drv_remove(struct platform_device *pdev)
 {
 	struct usb_hcd *hcd = platform_get_drvdata(pdev);
-	struct spear_ehci *sehci = to_spear_ehci(hcd);
+	struct spear_ehci *sehci;
 
 	if (!hcd)
 		return 0;
+
+	sehci = to_spear_ehci(hcd);
+
 	if (in_interrupt())
 		BUG();
 	usb_remove_hcd(hcd);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux