lkml.org 
[lkml]   [2021]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5.4 01/32] net: dsa: bcm_sf2: put device node before return
Hi!

> From: Pan Bian <bianpan2016@163.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
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2021-02-07 10:27    [W:0.163 / U:2.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site