Re: [PATCH net-next] net: gianfar: fix NVMEM mac address

From: Simon Horman
Date: Mon Sep 09 2024 - 14:49:02 EST


On Mon, Sep 09, 2024 at 11:20:20AM -0700, Rosen Penev wrote:
> On Mon, Sep 9, 2024 at 11:11 AM Rosen Penev <rosenp@xxxxxxxxx> wrote:
> >
> > On Mon, Sep 9, 2024 at 1:55 AM Simon Horman <horms@xxxxxxxxxx> wrote:
> > >
> > > On Sun, Sep 08, 2024 at 02:35:54PM -0700, Rosen Penev wrote:
> > > > If nvmem loads after the ethernet driver, mac address assignments will
> > > > not take effect. of_get_ethdev_address returns EPROBE_DEFER in such a
> > > > case so we need to handle that to avoid eth_hw_addr_random.
> > > >
> > > > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> > > > ---
> > > > drivers/net/ethernet/freescale/gianfar.c | 2 ++
> > > > 1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
> > > > index 634049c83ebe..9755ec947029 100644
> > > > --- a/drivers/net/ethernet/freescale/gianfar.c
> > > > +++ b/drivers/net/ethernet/freescale/gianfar.c
> > > > @@ -716,6 +716,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
> > > > priv->device_flags |= FSL_GIANFAR_DEV_HAS_BUF_STASHING;
> > > >
> > > > err = of_get_ethdev_address(np, dev);
> > > > + if (err == -EPROBE_DEFER)
> > > > + return err;
> > >
> > > To avoid leaking resources, I think this should be:
> > >
> > > goto err_grp_init;
> > will do in v2. Unfortunately net-next closes today AFAIK.
> On second thought, where did you find this?
>
> git grep err_grp_init
>
> returns nothing.
>
> Not only that, this function has no goto.

Maybe we are looking at different things for some reason.

I'm looking at this:

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/ethernet/freescale/gianfar.c?id=bfba7bc8b7c2c100b76edb3a646fdce256392129#n814

> > >
> > > Flagged by Smatch.
> > >
> > > > if (err) {
> > > > eth_hw_addr_random(dev);
> > > > dev_info(&ofdev->dev, "Using random MAC address: %pM\n", dev->dev_addr);
> > >
> > > --
> > > pw-bot: cr
>