From: Jiri Pirko Date: Thu, 25 Aug 2022 11:29:23 +0000 (+0200) Subject: net: devlink: add RNLT lock assertion to devlink_compat_switch_id_get() X-Git-Tag: v6.1-rc1~170^2~325 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6005a8aecee8afeba826295321a612ab485c230e;p=thirdparty%2Fkernel%2Flinux.git net: devlink: add RNLT lock assertion to devlink_compat_switch_id_get() Similar to devlink_compat_phys_port_name_get(), make sure that devlink_compat_switch_id_get() is called with RTNL lock held. Comment already says so, so put this in code as well. Signed-off-by: Jiri Pirko Link: https://lore.kernel.org/r/20220825112923.1359194-1-jiri@resnulli.us Signed-off-by: Jakub Kicinski --- diff --git a/net/core/devlink.c b/net/core/devlink.c index 0f7078db12800..2afbeb6eca672 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -12505,6 +12505,8 @@ int devlink_compat_switch_id_get(struct net_device *dev, * devlink_port instance cannot disappear in the middle. No need to take * any devlink lock as only permanent values are accessed. */ + ASSERT_RTNL(); + devlink_port = netdev_to_devlink_port(dev); if (!devlink_port || !devlink_port->switch_port) return -EOPNOTSUPP;