diff mbox series

[1/2] udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()

Message ID 20221126100634.106887-2-yuancan@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Add check for nla_nest_start() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yuan Can Nov. 26, 2022, 10:06 a.m. UTC
As the nla_nest_start() may fail with NULL returned, the return value needs
to be checked.

Fixes: c7d759eb7b12 ("ethtool: add tunnel info interface")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 net/ipv4/udp_tunnel_nic.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Ahern Nov. 27, 2022, 7:39 p.m. UTC | #1
On 11/26/22 3:06 AM, Yuan Can wrote:
> As the nla_nest_start() may fail with NULL returned, the return value needs
> to be checked.
> 
> Fixes: c7d759eb7b12 ("ethtool: add tunnel info interface")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> ---
>  net/ipv4/udp_tunnel_nic.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
> index bc3a043a5d5c..75a0caa4aebe 100644
> --- a/net/ipv4/udp_tunnel_nic.c
> +++ b/net/ipv4/udp_tunnel_nic.c
> @@ -624,6 +624,8 @@ __udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table,
>  			continue;
>  
>  		nest = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
> +		if (!nest)
> +			goto err_cancel;

no need to call nla_nest_cancel if nest_start fails.

>  
>  		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
>  				 utn->entries[table][j].port) ||
Yuan Can Nov. 29, 2022, 1:29 a.m. UTC | #2
在 2022/11/28 3:39, David Ahern 写道:
> On 11/26/22 3:06 AM, Yuan Can wrote:
>> As the nla_nest_start() may fail with NULL returned, the return value needs
>> to be checked.
>>
>> Fixes: c7d759eb7b12 ("ethtool: add tunnel info interface")
>> Signed-off-by: Yuan Can <yuancan@huawei.com>
>> ---
>>   net/ipv4/udp_tunnel_nic.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
>> index bc3a043a5d5c..75a0caa4aebe 100644
>> --- a/net/ipv4/udp_tunnel_nic.c
>> +++ b/net/ipv4/udp_tunnel_nic.c
>> @@ -624,6 +624,8 @@ __udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table,
>>   			continue;
>>   
>>   		nest = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
>> +		if (!nest)
>> +			goto err_cancel;
> no need to call nla_nest_cancel if nest_start fails.
Ok, thanks for the suggestion, it will be fixed in the next version.
diff mbox series

Patch

diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
index bc3a043a5d5c..75a0caa4aebe 100644
--- a/net/ipv4/udp_tunnel_nic.c
+++ b/net/ipv4/udp_tunnel_nic.c
@@ -624,6 +624,8 @@  __udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table,
 			continue;
 
 		nest = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
+		if (!nest)
+			goto err_cancel;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 utn->entries[table][j].port) ||