[PATCH v3] net: enetc: Fix use after free issue in fsl_enetc.c

Peng Fan peng.fan at oss.nxp.com
Mon Sep 26 09:38:57 CEST 2022



On 9/2/2022 2:51 PM, Siarhei Yasinski wrote:
> If ethernet connected to SFP, like this:
> 
> &enetc_port0 {
> 	phy-connection-type = "sgmii";
> 	sfp = <&sfp0>;
> 	managed = "in-band-status";
> 	status = "okay";
> };
> 
> Then enetc_config_phy returns -ENODEV and memory containing mdio interface
> is freeing. It's better to unregister and free mdio resources.
> 
> Signed-off-by: Siarhei Yasinski <siarhei.yasinski at sintecs.eu>

I merged a previous version which has 2 reviewed-by.

Is there any change in this version? and why drop R-b tag?

Thanks,
Peng.
> ---
>   drivers/net/fsl_enetc.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
> index cd4c2c29a6..b273aa7602 100644
> --- a/drivers/net/fsl_enetc.c
> +++ b/drivers/net/fsl_enetc.c
> @@ -22,6 +22,8 @@
>   
>   #define ENETC_DRIVER_NAME	"enetc_eth"
>   
> +static int enetc_remove(struct udevice *dev);
> +
>   /*
>    * sets the MAC address in IERB registers, this setting is persistent and
>    * carried over to Linux.
> @@ -319,6 +321,7 @@ static int enetc_config_phy(struct udevice *dev)
>   static int enetc_probe(struct udevice *dev)
>   {
>   	struct enetc_priv *priv = dev_get_priv(dev);
> +	int ret;
>   
>   	if (ofnode_valid(dev_ofnode(dev)) && !ofnode_is_available(dev_ofnode(dev))) {
>   		enetc_dbg(dev, "interface disabled\n");
> @@ -350,7 +353,10 @@ static int enetc_probe(struct udevice *dev)
>   
>   	enetc_start_pcs(dev);
>   
> -	return enetc_config_phy(dev);
> +	ret = enetc_config_phy(dev);
> +	if (ret)
> +		enetc_remove(dev);
> +	return ret;
>   }
>   
>   /*


More information about the U-Boot mailing list