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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALs4sv08GJXexShzkrhhW5CDSgJC0z3om5YJzy_qYRqEtvyMtg@mail.gmail.com>
Date: Fri, 14 Jul 2023 10:14:02 +0530
From: Pavan Chebbi <pavan.chebbi@...adcom.com>
To: Paul Fertser <fercerpav@...il.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, 
	Andrew Lunn <andrew@...n.ch>, Liang He <windhl@....com>, Geoff Levand <geoff@...radead.org>, 
	Leon Romanovsky <leon@...nel.org>, Tao Ren <rentao.bupt@...il.com>, 
	Wolfram Sang <wsa+renesas@...g-engineering.com>, openbmc@...ts.ozlabs.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: ftgmac100: support getting MAC address from NVMEM

On Thu, Jul 13, 2023 at 3:28 PM Paul Fertser <fercerpav@...il.com> wrote:
>
> Make use of of_get_ethdev_address() to support reading MAC address not
> only from the usual DT nodes but also from an NVMEM provider (e.g. using
> a dedicated area in an FRU EEPROM).
>

Looks like earlier ftgmac100_probe() would move on with self generated
(random) MAC addr if getting it from the device failed.
Now you will fail the probe in a failure case. Is that OK?

> Signed-off-by: Paul Fertser <fercerpav@...il.com>
> ---
>  drivers/net/ethernet/faraday/ftgmac100.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index a03879a27b04..9135b918dd49 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -177,16 +177,20 @@ static void ftgmac100_write_mac_addr(struct ftgmac100 *priv, const u8 *mac)
>         iowrite32(laddr, priv->base + FTGMAC100_OFFSET_MAC_LADR);
>  }
>
> -static void ftgmac100_initial_mac(struct ftgmac100 *priv)
> +static int ftgmac100_initial_mac(struct ftgmac100 *priv)
>  {
>         u8 mac[ETH_ALEN];
>         unsigned int m;
>         unsigned int l;
> +       int err;
>
> -       if (!device_get_ethdev_address(priv->dev, priv->netdev)) {
> +       err = of_get_ethdev_address(priv->dev->of_node, priv->netdev);
> +       if (err == -EPROBE_DEFER)
> +               return err;
> +       if (!err) {
>                 dev_info(priv->dev, "Read MAC address %pM from device tree\n",
>                          priv->netdev->dev_addr);
> -               return;
> +               return 0;
>         }
>
>         m = ioread32(priv->base + FTGMAC100_OFFSET_MAC_MADR);
> @@ -207,6 +211,8 @@ static void ftgmac100_initial_mac(struct ftgmac100 *priv)
>                 dev_info(priv->dev, "Generated random MAC address %pM\n",
>                          priv->netdev->dev_addr);
>         }
> +
> +       return 0;
>  }
>
>  static int ftgmac100_set_mac_addr(struct net_device *dev, void *p)
> @@ -1843,7 +1849,9 @@ static int ftgmac100_probe(struct platform_device *pdev)
>         priv->aneg_pause = true;
>
>         /* MAC address from chip or random one */
> -       ftgmac100_initial_mac(priv);
> +       err = ftgmac100_initial_mac(priv);
> +       if (err)
> +               goto err_phy_connect;
>
>         np = pdev->dev.of_node;
>         if (np && (of_device_is_compatible(np, "aspeed,ast2400-mac") ||
> --
> 2.34.1
>
>

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ