[U-Boot] [PATCH 2/3] usb: ehci: Do not de-init uninited controllers
Simon Glass
sjg at chromium.org
Fri Dec 27 00:08:54 CET 2013
On 13 December 2013 21:55, Marek Vasut <marex at denx.de> wrote:
> 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 at denx.de>
> Cc: Simon Glass <sjg at chromium.org>
>
Acked-by: Simon Glass <sjg at chromium.org>
> ---
> drivers/usb/host/ehci-hcd.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 8bd1eb8..3ef204d 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -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);
> --
> 1.8.4.3
>
>
More information about the U-Boot
mailing list