devlink: always check if the devlink instance is registered
authorJakub Kicinski <kuba@kernel.org>
Fri, 6 Jan 2023 06:33:57 +0000 (22:33 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Jan 2023 12:56:19 +0000 (12:56 +0000)
commited539ba614a079ea696b92beef1eafec66f831a4
tree4c6df2d81001a8a5243d9cb9b9d390a68b98c7ff
parent870c7ad4a52be2acff92d0355ca118654c7efece
devlink: always check if the devlink instance is registered

Always check under the instance lock whether the devlink instance
is still / already registered.

This is a no-op for the most part, as the unregistration path currently
waits for all references. On the init path, however, we may temporarily
open up a race with netdev code, if netdevs are registered before the
devlink instance. This is temporary, the next change fixes it, and this
commit has been split out for the ease of review.

Note that in case of iterating over sub-objects which have their
own lock (regions and line cards) we assume an implicit dependency
between those objects existing and devlink unregistration.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/devlink/core.c
net/devlink/devl_internal.h
net/devlink/leftover.c
net/devlink/netlink.c