[U-Boot] [PATCH 1/1] dm: usb: ehci: avoid possible NULL dereference
Marek Vasut
marex at denx.de
Mon Nov 20 00:47:20 UTC 2017
On 11/19/2017 11:42 PM, Heinrich Schuchardt wrote:
> It is unwise to first dereference a pointer and
> afterwards to check if it was NULL.
The check is still incomplete, the hccr is not checked.
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> drivers/usb/host/ehci-hcd.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index be3e842dcc..80bc8219af 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -208,11 +208,13 @@ static int ehci_shutdown(struct ehci_ctrl *ctrl)
> {
> int i, ret = 0;
> uint32_t cmd, reg;
> - int max_ports = HCS_N_PORTS(ehci_readl(&ctrl->hccr->cr_hcsparams));
> + int max_ports;
>
> if (!ctrl || !ctrl->hcor)
> return -EINVAL;
>
> + max_ports = HCS_N_PORTS(ehci_readl(&ctrl->hccr->cr_hcsparams));
> +
> cmd = ehci_readl(&ctrl->hcor->or_usbcmd);
> /* If not run, directly return */
> if (!(cmd & CMD_RUN))
>
--
Best regards,
Marek Vasut
More information about the U-Boot
mailing list