Subject: Re: [PATCH net v2] net: ethernet: ti: am65-cpsw: Fix devlink port register sequence

From: Jakub Kicinski <[email-masked]>
Date: Tue, 5 Jul 2022 18:39:01 -0700

On Mon, 4 Jul 2022 13:00:40 +0530 Siddharth Vadapalli wrote:
> @@ -2527,6 +2527,10 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
>  		return ret;
>  	}
>  
> +	ret = am65_cpsw_nuss_register_devlink(common);
> +	if (ret)
> +		goto err_cleanup_ndev;
> +
>  	for (i = 0; i < common->port_num; i++) {
>  		port = &common->ports[i];
>  
> @@ -2539,23 +2543,21 @@ static int am65_cpsw_nuss_register_ndevs(struct am65_cpsw_common *common)
>  				i, ret);
>  			goto err_cleanup_ndev;
>  		}
> +
> +		dl_port = &port->devlink_port;
> +		devlink_port_type_eth_set(dl_port, port->ndev);
>  	}
>  
>  	ret = am65_cpsw_register_notifiers(common);
>  	if (ret)
>  		goto err_cleanup_ndev;
>  
> -	ret = am65_cpsw_nuss_register_devlink(common);
> -	if (ret)
> -		goto clean_unregister_notifiers;
> -
>  	/* can't auto unregister ndev using devm_add_action() due to
>  	 * devres release sequence in DD core for DMA
>  	 */
>  
>  	return 0;
> -clean_unregister_notifiers:
> -	am65_cpsw_unregister_notifiers(common);
> +
>  err_cleanup_ndev:
>  	am65_cpsw_nuss_cleanup_ndev(common);

No additions to the error handling path? Slightly suspicious.
Do the devlink ports not have to be removed if netdev registration
fails?