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

Signed-off-by: Vladimir Oltean <vladimir.olt...@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

Reply via email to