ionic: cleanly release devlink instance
authorLeon Romanovsky <leonro@nvidia.com>
Wed, 21 Jul 2021 12:39:44 +0000 (15:39 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Sep 2021 07:50:33 +0000 (09:50 +0200)
commit83f7297a4af45a4dbfa14b02f8215b686d60d167
tree766fc6616648784b8a0e800fbeb32e929334521f
parent203537ff35eac98544fb35751826e66ea6cb7da6
ionic: cleanly release devlink instance

[ Upstream commit c2255ff47768c94a0ebc3968f007928bb47ea43b ]

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@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/pensando/ionic/ionic_devlink.c