usb: ehci: Do not de-init uninited controllers
authorMarek Vasut <marex@denx.de>
Sat, 14 Dec 2013 01:03:11 +0000 (02:03 +0100)
committerMarek Vasut <marex@denx.de>
Wed, 18 Dec 2013 18:53:19 +0000 (19:53 +0100)
In case the controller is not initialized, we shall not de-initialize it.
As the control structure will not be filled, we will produce a null ptr
dereference if the controller is not inited.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Simon Glass <sjg@chromium.org>
drivers/usb/host/ehci-hcd.c

index 8bd1eb8a99836f16f95113ac6d2e68b339cf5489..3ef204d6abce24801d7f507cb828c48818dedfca 100644 (file)
@@ -201,6 +201,9 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl)
        int i, ret = 0;
        uint32_t cmd, reg;
 
+       if (!ctrl || !ctrl->hcor)
+               return -EINVAL;
+
        cmd = ehci_readl(&ctrl->hcor->or_usbcmd);
        cmd &= ~(CMD_PSE | CMD_ASE);
        ehci_writel(&ctrl->hcor->or_usbcmd, cmd);