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

Ramon Fried rfried.dev at gmail.com
Tue Sep 28 15:27:10 CEST 2021


On Mon, Sep 27, 2021 at 2:22 PM Vladimir Oltean <vladimir.oltean at nxp.com> wrote:
>
> 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
>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list