From 4df9f5e39fb224a4857c3411b4cbe419e4d339e8 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Mon, 27 Sep 2021 14:22:05 +0300 Subject: [PATCH] scripts: ensure the cocci script for miiphy_register does not leak the MDIO bus When mdio_register fails, mdio_free should be called on the mdiodev that was previously allocated with mdio_alloc. Signed-off-by: Vladimir Oltean --- scripts/coccinelle/net/mdio_register.cocci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/coccinelle/net/mdio_register.cocci b/scripts/coccinelle/net/mdio_register.cocci index 31a40360f9..7d11281f46 100644 --- a/scripts/coccinelle/net/mdio_register.cocci +++ b/scripts/coccinelle/net/mdio_register.cocci @@ -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; -- 2.39.5