[PATCH] drivers: net: fsl_ls_mdio: prevent a NULL pointer dereference

Ramon Fried rfried.dev at gmail.com
Tue Jan 10 18:09:06 CET 2023


On Thu, Jan 5, 2023 at 5:09 PM Ioana Ciornei <ioana.ciornei at nxp.com> wrote:
>
> 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 at nxp.com>
> ---
>  drivers/net/fsl_ls_mdio.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/fsl_ls_mdio.c b/drivers/net/fsl_ls_mdio.c
> index f213e0dd8590..fce73937502d 100644
> --- a/drivers/net/fsl_ls_mdio.c
> +++ b/drivers/net/fsl_ls_mdio.c
> @@ -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,
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list