[PATCH 24/25] arch: powerpc: mpc85xx: free MDIO bus if mdio_register fails

Vladimir Oltean vladimir.oltean at nxp.com
Mon Sep 27 13:22:04 CEST 2021


If mdio_register fails, it is nice to not leave behind dangling
allocated memory.

Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
---
 arch/powerpc/cpu/mpc85xx/ether_fcc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/cpu/mpc85xx/ether_fcc.c b/arch/powerpc/cpu/mpc85xx/ether_fcc.c
index 1f6f55707321..5cf0a3fb227a 100644
--- a/arch/powerpc/cpu/mpc85xx/ether_fcc.c
+++ b/arch/powerpc/cpu/mpc85xx/ether_fcc.c
@@ -449,8 +449,10 @@ int fec_initialize(struct bd_info *bis)
 		mdiodev->write = bb_miiphy_write;
 
 		retval = mdio_register(mdiodev);
-		if (retval < 0)
+		if (retval < 0) {
+			mdio_free(mdiodev);
 			return retval;
+		}
 #endif
 	}
 
-- 
2.25.1



More information about the U-Boot mailing list