diff mbox series

[net-next] rtnetlink: Move nesting cancellation rollback to proper function

Message ID 20230713141652.2288309-1-gal@nvidia.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] rtnetlink: Move nesting cancellation rollback to proper function | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1343 this patch: 1343
netdev/cc_maintainers warning 4 maintainers not CCed: razor@blackwall.org idosch@nvidia.com edwin.peer@broadcom.com lucien.xin@gmail.com
netdev/build_clang success Errors and warnings before: 1364 this patch: 1364
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1366 this patch: 1366
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Gal Pressman July 13, 2023, 2:16 p.m. UTC
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>
---
 net/core/rtnetlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Simon Horman July 15, 2023, 10:11 a.m. UTC | #1
On Thu, Jul 13, 2023 at 05:16:52PM +0300, Gal Pressman wrote:
> 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>
> ---
>  net/core/rtnetlink.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 3ad4e030846d..ed9b41ab9afc 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1343,7 +1343,7 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
>  	vf_trust.setting = ivi.trusted;
>  	vf = nla_nest_start_noflag(skb, IFLA_VF_INFO);
>  	if (!vf)
> -		goto nla_put_vfinfo_failure;
> +		return -EMSGSIZE;
>  	if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
>  	    nla_put(skb, IFLA_VF_BROADCAST, sizeof(vf_broadcast), &vf_broadcast) ||
>  	    nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
> @@ -1414,8 +1414,6 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
>  
>  nla_put_vf_failure:
>  	nla_nest_cancel(skb, vf);
> -nla_put_vfinfo_failure:
> -	nla_nest_cancel(skb, vfinfo);

It seems that the vfinfo parameter of rtnl_fill_vfinfo() is now unused.
Can it be removed?

>  	return -EMSGSIZE;
>  }
>  
> @@ -1441,8 +1439,10 @@ static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,
>  		return -EMSGSIZE;
>  
>  	for (i = 0; i < num_vfs; i++) {
> -		if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask))
> +		if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask)) {
> +			nla_nest_cancel(skb, vfinfo);
>  			return -EMSGSIZE;
> +		}
>  	}
>  
>  	nla_nest_end(skb, vfinfo);
> -- 
> 2.40.1
> 
>
Gal Pressman July 16, 2023, 6:53 a.m. UTC | #2
On 15/07/2023 13:11, Simon Horman wrote:
> On Thu, Jul 13, 2023 at 05:16:52PM +0300, Gal Pressman wrote:
>> 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>
>> ---
>>  net/core/rtnetlink.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>> index 3ad4e030846d..ed9b41ab9afc 100644
>> --- a/net/core/rtnetlink.c
>> +++ b/net/core/rtnetlink.c
>> @@ -1343,7 +1343,7 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
>>  	vf_trust.setting = ivi.trusted;
>>  	vf = nla_nest_start_noflag(skb, IFLA_VF_INFO);
>>  	if (!vf)
>> -		goto nla_put_vfinfo_failure;
>> +		return -EMSGSIZE;
>>  	if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
>>  	    nla_put(skb, IFLA_VF_BROADCAST, sizeof(vf_broadcast), &vf_broadcast) ||
>>  	    nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
>> @@ -1414,8 +1414,6 @@ static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
>>  
>>  nla_put_vf_failure:
>>  	nla_nest_cancel(skb, vf);
>> -nla_put_vfinfo_failure:
>> -	nla_nest_cancel(skb, vfinfo);
> 
> It seems that the vfinfo parameter of rtnl_fill_vfinfo() is now unused.
> Can it be removed?

Good catch, will do, thanks.
diff mbox series

Patch

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3ad4e030846d..ed9b41ab9afc 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1343,7 +1343,7 @@  static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
 	vf_trust.setting = ivi.trusted;
 	vf = nla_nest_start_noflag(skb, IFLA_VF_INFO);
 	if (!vf)
-		goto nla_put_vfinfo_failure;
+		return -EMSGSIZE;
 	if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
 	    nla_put(skb, IFLA_VF_BROADCAST, sizeof(vf_broadcast), &vf_broadcast) ||
 	    nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
@@ -1414,8 +1414,6 @@  static noinline_for_stack int rtnl_fill_vfinfo(struct sk_buff *skb,
 
 nla_put_vf_failure:
 	nla_nest_cancel(skb, vf);
-nla_put_vfinfo_failure:
-	nla_nest_cancel(skb, vfinfo);
 	return -EMSGSIZE;
 }
 
@@ -1441,8 +1439,10 @@  static noinline_for_stack int rtnl_fill_vf(struct sk_buff *skb,
 		return -EMSGSIZE;
 
 	for (i = 0; i < num_vfs; i++) {
-		if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask))
+		if (rtnl_fill_vfinfo(skb, dev, i, vfinfo, ext_filter_mask)) {
+			nla_nest_cancel(skb, vfinfo);
 			return -EMSGSIZE;
+		}
 	}
 
 	nla_nest_end(skb, vfinfo);