[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04d36c6b-1e8d-117f-3079-8314f6b8051d@pensando.io>
Date: Wed, 21 Jul 2021 08:55:56 -0700
From: Shannon Nelson <snelson@...sando.io>
To: Leon Romanovsky <leon@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: Leon Romanovsky <leonro@...dia.com>, drivers@...sando.io,
linux-kernel@...r.kernel.org, Moshe Shemesh <moshe@...dia.com>,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next] ionic: cleanly release devlink instance
On 7/21/21 5:39 AM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@...dia.com>
>
> The failure to register devlink will leave the system with dangled
> devlink resource, which is not cleaned if devlink_port_register() fails.
>
> In order to remove access to ".registered" field of struct devlink_port,
> require both devlink_register and devlink_port_register to success and
> check it through device pointer.
>
> Fixes: fbfb8031533c ("ionic: Add hardware init and device commands")
> Reviewed-by: Moshe Shemesh <moshe@...dia.com>
> Signed-off-by: Leon Romanovsky <leonro@...dia.com>
Sure, thanks.
Acked-by: Shannon Nelson <snelson@...sando.io>
> ---
> Future series will remove .registered field from the devlink.
> ---
> .../net/ethernet/pensando/ionic/ionic_devlink.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> index b41301a5b0df..cd520e4c5522 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> @@ -91,20 +91,20 @@ int ionic_devlink_register(struct ionic *ionic)
> attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
> devlink_port_attrs_set(&ionic->dl_port, &attrs);
> err = devlink_port_register(dl, &ionic->dl_port, 0);
> - if (err)
> + if (err) {
> dev_err(ionic->dev, "devlink_port_register failed: %d\n", err);
> - else
> - devlink_port_type_eth_set(&ionic->dl_port,
> - ionic->lif->netdev);
> + devlink_unregister(dl);
> + return err;
> + }
>
> - return err;
> + devlink_port_type_eth_set(&ionic->dl_port, ionic->lif->netdev);
> + return 0;
> }
>
> void ionic_devlink_unregister(struct ionic *ionic)
> {
> struct devlink *dl = priv_to_devlink(ionic);
>
> - if (ionic->dl_port.registered)
> - devlink_port_unregister(&ionic->dl_port);
> + devlink_port_unregister(&ionic->dl_port);
> devlink_unregister(dl);
> }
Powered by blists - more mailing lists