[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210207092527.GB32297@amd>
Date: Sun, 7 Feb 2021 10:25:27 +0100
From: Pavel Machek <pavel@....cz>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Pan Bian <bianpan2016@....com>,
Jakub Kicinski <kuba@...nel.org>
Subject: Re: [PATCH 5.4 01/32] net: dsa: bcm_sf2: put device node before
return
Hi!
> From: Pan Bian <bianpan2016@....com>
>
> commit cf3c46631e1637582f517a574c77cd6c05793817 upstream.
>
> Put the device node dn before return error code on failure path.
This fixes one resource leak, but exposes next one: get_device() is
not undone in the second error path and in the end of function.
Best regards,
Pavel
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -421,15 +421,19 @@ static int bcm_sf2_mdio_register(struct
> /* Find our integrated MDIO bus node */
> dn = of_find_compatible_node(NULL, NULL, "brcm,unimac-mdio");
> priv->master_mii_bus = of_mdio_find_bus(dn);
> - if (!priv->master_mii_bus)
> + if (!priv->master_mii_bus) {
> + of_node_put(dn);
> return -EPROBE_DEFER;
> + }
>
> get_device(&priv->master_mii_bus->dev);
> priv->master_mii_dn = dn;
>
> priv->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
> - if (!priv->slave_mii_bus)
> + if (!priv->slave_mii_bus) {
> + of_node_put(dn);
> return -ENOMEM;
> + }
>
> priv->slave_mii_bus->priv = priv;
> priv->slave_mii_bus->name = "sf2 slave mii";
>
--
http://www.livejournal.com/~pavelmachek
Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)
Powered by blists - more mailing lists