[U-Boot] [PATCH 1/1] dm: usb: ehci: avoid possible NULL dereference
Heinrich Schuchardt
xypron.glpk at gmx.de
Sun Nov 19 22:42:45 UTC 2017
It is unwise to first dereference a pointer and
afterwards to check if it was NULL.
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))
--
2.15.0
More information about the U-Boot
mailing list