xhci: tegra: fix kernel panic in tegra_xhci_remove
JC Kuo [Fri, 13 Sep 2013 07:06:50 +0000 (15:06 +0800)]
tegra_xhci_remove() calls usb_unregister_notifier() with parameters
are NULL pointers. That causes kernel panic. This change fixes it.

bug 1368024

Change-Id: I10ea852659afece3b0ae18c2989ad85ee392e3c3
Signed-off-by: JC Kuo <jckuo@nvidia.com>
Reviewed-on: http://git-master/r/274150
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Tested-by: Sachin Nikam <snikam@nvidia.com>
(cherry picked from commit 10906950e03608b6a4a5322693bf9793e1ba175d)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>

drivers/usb/host/xhci-tegra.c

index c0a2ace..d54d83f 100644 (file)
@@ -4346,8 +4346,9 @@ err_deinit_usb2_clocks:
 err_deinit_tegra_xusb_regulator:
        tegra_xusb_regulator_deinit(tegra);
 err_deinit_xusb_partition_clk:
-       usb_unregister_notifier(tegra->transceiver,
-               &tegra->otgnb);
+       if (tegra->transceiver)
+               usb_unregister_notifier(tegra->transceiver, &tegra->otgnb);
+
        tegra_xusb_partitions_clk_deinit(tegra);
 
        return ret;
@@ -4383,8 +4384,10 @@ static int tegra_xhci_remove(struct platform_device *pdev)
        deinit_firmware(tegra);
        fw_log_deinit(tegra);
        tegra_xusb_regulator_deinit(tegra);
-       usb_unregister_notifier(tegra->transceiver,
-               &tegra->otgnb);
+
+       if (tegra->transceiver)
+               usb_unregister_notifier(tegra->transceiver, &tegra->otgnb);
+
        tegra_usb2_clocks_deinit(tegra);
        if (!tegra->hc_in_elpg)
                tegra_xusb_partitions_clk_deinit(tegra);