'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.ka...@linaro.org>
Cc: Viresh Kumar <viresh.ku...@linaro.org>
---
 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to