]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
drivers: net: fsl_ls_mdio: prevent a NULL pointer dereference
authorIoana Ciornei <ioana.ciornei@nxp.com>
Thu, 5 Jan 2023 15:09:48 +0000 (17:09 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 2 Feb 2023 19:44:53 +0000 (14:44 -0500)
Prevent a NULL pointer dereference in the probe path by checking the
return valud of dev_read_addr_ptr() against NULL.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
drivers/net/fsl_ls_mdio.c

index f213e0dd85901a4d094300fbf53ca5b992329f4e..fce73937502df8c49f1507b7bfa36ff19d24629d 100644 (file)
@@ -124,6 +124,9 @@ static int fsl_ls_mdio_probe(struct udevice *dev)
        struct memac_mdio_controller *regs;
 
        priv->regs_base = dev_read_addr_ptr(dev);
+       if (!priv->regs_base)
+               return -ENODEV;
+
        regs = (struct memac_mdio_controller *)(priv->regs_base);
 
        memac_setbits_32(&regs->mdio_stat,