All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramon Fried <rfried.dev@gmail.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Joe Hershberger <joe.hershberger@ni.com>
Subject: Re: [PATCH 22/25] net: dsa: felix: check return code of mdio_alloc and mdio_register
Date: Tue, 28 Sep 2021 16:33:51 +0300	[thread overview]
Message-ID: <CAGi-RUL7Yg0Yw7FqFZJkXPHu6ToDiE66A+RcbJhuGGXXwKXmrA@mail.gmail.com> (raw)
In-Reply-To: <20210927112205.301876-23-vladimir.oltean@nxp.com>

On Mon, Sep 27, 2021 at 2:22 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> These functions can return errors, it's best to catch them and trigger
> the driver unwind code path.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/mscc_eswitch/felix_switch.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/mscc_eswitch/felix_switch.c b/drivers/net/mscc_eswitch/felix_switch.c
> index 4c2e57755967..98ae39e81d65 100644
> --- a/drivers/net/mscc_eswitch/felix_switch.c
> +++ b/drivers/net/mscc_eswitch/felix_switch.c
> @@ -276,6 +276,7 @@ static void felix_init(struct udevice *dev)
>  static int felix_probe(struct udevice *dev)
>  {
>         struct felix_priv *priv = dev_get_priv(dev);
> +       int err;
>
>         if (ofnode_valid(dev_ofnode(dev)) &&
>             !ofnode_is_available(dev_ofnode(dev))) {
> @@ -300,11 +301,18 @@ static int felix_probe(struct udevice *dev)
>                 struct mii_dev *mii_bus;
>
>                 mii_bus = mdio_alloc();
> +               if (!mii_bus)
> +                       return -ENOMEM;
> +
>                 mii_bus->read = felix_mdio_read;
>                 mii_bus->write = felix_mdio_write;
>                 mii_bus->priv = priv->imdio_base + FELIX_PM_IMDIO_BASE;
>                 strlcpy(mii_bus->name, dev->name, MDIO_NAME_LEN);
> -               mdio_register(mii_bus);
> +               err = mdio_register(mii_bus);
> +               if (err) {
> +                       mdio_free(mii_bus);
> +                       return err;
> +               }
>         }
>
>         dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY);
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

  reply	other threads:[~2021-09-28 13:37 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 11:21 [PATCH 00/25] Fix some non-NULL terminated strings in the networking subsystem Vladimir Oltean
2021-09-27 11:21 ` [PATCH 01/25] arch: powerpc: mpc85xx: ensure mdiodev->name is NULL terminated after MDIO_NAME_LEN truncation Vladimir Oltean
2021-09-28 13:24   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 02/25] board: gdsys: a38x: " Vladimir Oltean
2021-09-28 13:24   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 03/25] net: armada100_fec: " Vladimir Oltean
2021-09-28 13:31   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 04/25] net: at91_emac: " Vladimir Oltean
2021-09-28 13:31   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 05/25] net: bcm-sf2: " Vladimir Oltean
2021-09-28 13:31   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 06/25] net: eepro100: " Vladimir Oltean
2021-09-28 13:31   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 07/25] net: ep93xx: " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 08/25] net: enetc: ensure imdio.name " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 09/25] net: mcdmafec: ensure bus->name " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 10/25] net: ftmac110: ensure mdiodev->name " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 11/25] net: lpc32xx: " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 12/25] net: macb: " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 13/25] net: mpc8xx_fec: " Vladimir Oltean
2021-09-28 13:32   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 14/25] net: dsa: felix: ensure mii_bus->name " Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 15/25] net: mvgbe: ensure mdiodev->name " Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 16/25] net: sh_eth: " Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 17/25] net: smc911x: " Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 18/25] net: davinci_emac: " Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:21 ` [PATCH 19/25] net: qe: uec: " Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:22 ` [PATCH 20/25] net: mdio-uclass: rewrite dm_mdio_post_probe using strlcpy Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:22 ` [PATCH 21/25] scripts: ensure the cocci script for miiphy_register does not leave NULL-unterminated strings Vladimir Oltean
2021-09-27 11:22 ` [PATCH 22/25] net: dsa: felix: check return code of mdio_alloc and mdio_register Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried [this message]
2021-09-27 11:22 ` [PATCH 23/25] net: dsa: ensure port names are NULL-terminated after DSA_PORT_NAME_LENGTH truncation Vladimir Oltean
2021-09-28 13:33   ` Ramon Fried
2021-09-27 11:22 ` [PATCH 24/25] arch: powerpc: mpc85xx: free MDIO bus if mdio_register fails Vladimir Oltean
2021-09-28 13:27   ` Ramon Fried
2021-09-27 11:22 ` [PATCH 25/25] scripts: ensure the cocci script for miiphy_register does not leak the MDIO bus Vladimir Oltean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGi-RUL7Yg0Yw7FqFZJkXPHu6ToDiE66A+RcbJhuGGXXwKXmrA@mail.gmail.com \
    --to=rfried.dev@gmail.com \
    --cc=joe.hershberger@ni.com \
    --cc=u-boot@lists.denx.de \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.