]> git.baikalelectronics.ru Git - uboot.git/commitdiff
scripts: ensure the cocci script for miiphy_register does not leak the MDIO bus
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 27 Sep 2021 11:22:05 +0000 (14:22 +0300)
committerRamon Fried <rfried.dev@gmail.com>
Tue, 28 Sep 2021 15:50:57 +0000 (18:50 +0300)
When mdio_register fails, mdio_free should be called on the mdiodev that
was previously allocated with mdio_alloc.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
scripts/coccinelle/net/mdio_register.cocci

index 31a40360f99e9af18d7c00380866e9d8511ad854..7d11281f4678bd3b98b648228553a5333992f7f4 100644 (file)
@@ -21,7 +21,7 @@ identifier readfunc, writefunc;
 + mdiodev->write = writefunc;
 + 
 + retval = mdio_register(mdiodev);
-+ if (retval < 0) return retval;
++ if (retval < 0) { mdio_free(mdiodev); return retval; }
 
 @ update_read_sig @
 identifier mii_reg.readfunc;