lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJq09z45WQv-F9dw-y13E_6DXAfmpxH20JnRoO10za3cuS2kZw@mail.gmail.com>
Date: Fri, 8 Dec 2023 15:05:41 -0300
From: Luiz Angelo Daros de Luca <luizluca@...il.com>
To: Alvin Šipraga <ALSI@...g-olufsen.dk>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>, 
	"linus.walleij@...aro.org" <linus.walleij@...aro.org>, "andrew@...n.ch" <andrew@...n.ch>, 
	"f.fainelli@...il.com" <f.fainelli@...il.com>, "olteanv@...il.com" <olteanv@...il.com>, 
	"davem@...emloft.net" <davem@...emloft.net>, "edumazet@...gle.com" <edumazet@...gle.com>, 
	"kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>, 
	"arinc.unal@...nc9.com" <arinc.unal@...nc9.com>
Subject: Re: [PATCH net-next 2/7] net: dsa: realtek: put of node after MDIO registration

> On Fri, Dec 08, 2023 at 02:13:25AM -0300, Luiz Angelo Daros de Luca wrote:
> > > diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c
> > > index 755546ed8db6..ddcae546afbc 100644
> > > --- a/drivers/net/dsa/realtek/realtek-smi.c
> > > +++ b/drivers/net/dsa/realtek/realtek-smi.c
> > > @@ -389,15 +389,15 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds)
> > >         priv->user_mii_bus->write = realtek_smi_mdio_write;
> > >         snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d",
> > >                  ds->index);
> > > -       priv->user_mii_bus->dev.of_node = mdio_np;
>
> You do not really justify removing this in your patch. This is not a
> purely cosmetic change because now the associated mdiodev will not be
> associated with the OF node. I don't know if there is any consequence to
> that but it is usually nice to populate this info in the device struct
> when it is actually available.

Reviewing the code again, I believe it was not just misplacing the
of_put_node() but probably calling it twice.

devm_mdiobus_alloc() doesn't set the dev in mii_bus. So, dev is all
zeros. The dev.of_node normal place to be defined is:

devm_of_mdiobus_register()
  __devm_of_mdiobus_register()
    __of_mdiobus_register()
      device_set_node()

The only way for that value, set by the line I removed, to persist is
when the devm_of_mdiobus_register() fails before device_set_node(). My
guess is that it was set to be used by realtek_smi_remove() if it is
called when registration fails. However, in that case, both
realtek_smi_setup_mdio() and realtek_smi_setup_mdio() would put the
node. So, either the line is useless or it will effectively result in
calling of_node_put() twice.

If I really needed to put that node in the realtek_smi_remove(), I
would use a dedicated field in realtek_priv instead of reusing a
reference for it inside another structure.

I'll add some notes to the commit message about all these but moving
the of_node_put() to the same function that gets the node solved all
the issues.

Regards,

Luiz

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ