Subject: Re: [PATCHv4 net] net: asix: fix modprobe "sysfs: cannot create duplicate filename"

From: Jakub Kicinski <[email-masked]>
Date: Wed, 15 Mar 2023 22:08:22 -0700

On Mon, 13 Mar 2023 22:54:10 -0700 Grant Grundler wrote:
> @@ -690,6 +704,7 @@ static int ax88772_init_phy(struct usbnet *dev)
>  	priv->phydev = mdiobus_get_phy(priv->mdio, priv->phy_addr);
>  	if (!priv->phydev) {
>  		netdev_err(dev->net, "Could not find PHY\n");
> +		ax88772_mdio_unregister(priv);

this line needs to go now..

>  		return -ENODEV;

.. since if we return error here ..

>  	}
>  
> @@ -896,16 +911,23 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
>  
>  	ret = ax88772_init_mdio(dev);
>  	if (ret)
> -		return ret;
> +		goto mdio_err;
>  
>  	ret = ax88772_phylink_setup(dev);
>  	if (ret)
> -		return ret;
> +		goto phylink_err;
>  
>  	ret = ax88772_init_phy(dev);

.. it will pop out here ..

>  	if (ret)
> -		phylink_destroy(priv->phylink);
> +		goto initphy_err;
>  
> +	return 0;
> +
> +initphy_err:
> +	phylink_destroy(priv->phylink);
> +phylink_err:
> +	ax88772_mdio_unregister(priv);

.. and then call ax88772_mdio_unregister() a second time.

> +mdio_err:
>  	return ret;
>  }