Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtnetlink: Move nesting cancellation rollback to proper function

Make rtnl_fill_vf() cancel the vfinfo attribute on error instead of the
inner rtnl_fill_vfinfo(), as it is the function that starts it.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Link: https://lore.kernel.org/r/20230716072440.2372567-1-gal@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Gal Pressman and committed by
Paolo Abeni
4a59cdfd d3750076

+4 -5
+4 -5
net/core/rtnetlink.c
··· 1273 1273 static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb, 1274 1274 struct net_device *dev, 1275 1275 int vfs_num, 1276 - struct nlattr *vfinfo, 1277 1276 u32 ext_filter_mask) 1278 1277 { 1279 1278 struct ifla_vf_rss_query_en vf_rss_query_en; ··· 1342 1343 vf_trust.setting = ivi.trusted; 1343 1344 vf = nla_nest_start_noflag(skb, IFLA_VF_INFO); 1344 1345 if (!vf) 1345 - goto nla_put_vfinfo_failure; 1346 + return -EMSGSIZE; 1346 1347 if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) || 1347 1348 nla_put(skb, IFLA_VF_BROADCAST, sizeof(vf_broadcast), &vf_broadcast) || 1348 1349 nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) || ··· 1413 1414 1414 1415 nla_put_vf_failure: 1415 1416 nla_nest_cancel(skb, vf); 1416 - nla_put_vfinfo_failure: 1417 - nla_nest_cancel(skb, vfinfo); 1418 1417 return -EMSGSIZE; 1419 1418 } 1420 1419 ··· 1438 1441 return -EMSGSIZE; 1439 1442 1440 1443 for (i = 0; i < num_vfs; i++) { 1441 - if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask)) 1444 + if (rtnl_fill_vfinfo(skb, dev, i, ext_filter_mask)) { 1445 + nla_nest_cancel(skb, vfinfo); 1442 1446 return -EMSGSIZE; 1447 + } 1443 1448 } 1444 1449 1445 1450 nla_nest_end(skb, vfinfo);