Skip to contentSkip to conversation

net/ethtool/tunnels: check the return value of nla_nest_start()

PATCH In review Li Zhong 2 participants 5 messages Sep 17, 2022 – Sep 21, 2022

Subsystems (3)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 net/ethtool/tunnels: check the return value of nla_nest_start()

Check the return value of nla_nest_start(), which could be NULL on error.

---
 net/ethtool/tunnels.c | 2 ++
 1 file changed, 2 insertions(+)
net/ethtool/tunnels.c +2 -0
index efde33536687..90974b625cf6 100644
@@ -136,6 +136,8 @@ ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base,
 			goto err_cancel_table;
 
 		entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
+		if (!entry)
+			return -EMSGSIZE;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 htons(IANA_VXLAN_UDP_PORT)) ||
Signature · 1 line
2.25.1
maintainer
#1 lore raw

net/ethtool/tunnels.c ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base, · line 140

Quoted 5 lines · On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
net/ethtool/tunnels.c +2 -0
 			goto err_cancel_table;
 
 		entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
+		if (!entry)
+			return -EMSGSIZE;

not even correct, and completely harmless

author
#2 lore raw
Quoted 9 lines · Jakub Kicinski

net/ethtool/tunnels.c ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base, · line 140

Quoted 5 lines · On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
                      goto err_cancel_table;

              entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
net/ethtool/tunnels.c +2 -0
+             if (!entry)
+                     return -EMSGSIZE;

not even correct, and completely harmless

Thanks for your reply. Maybe a more suitable way of error handling is 'goto err_cancel_table;'?

maintainer
#3 lore raw
Quoted 4 lines · On Tue, 20 Sep 2022 12:31:29 -0700 Li Zhong wrote:
Quoted 3 lines · Jakub Kicinski
Quoted 2 lines · On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
                      goto err_cancel_table;
Quoted 8 lines
Quoted 5 lines

net/ethtool/tunnels.c ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base, · line 140

Quoted 3 lines
              entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
net/ethtool/tunnels.c +2 -0
+             if (!entry)
+                     return -EMSGSIZE;  

not even correct, and completely harmless

Thanks for your reply. Maybe a more suitable way of error handling is 'goto err_cancel_table;'?

Yes, but you _most_ provide the detailed analysis of the impact in the commit message for the patches to be considered for merging.

author
#4 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 8 lines · On Tue, 20 Sep 2022 12:31:29 -0700 Li Zhong wrote:
Quoted 7 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 16 Sep 2022 19:26:02 -0700 Li Zhong wrote:
                      goto err_cancel_table;

              entry = nla_nest_start(skb, ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY);
net/ethtool/tunnels.c +2 -0
+             if (!entry)
+                     return -EMSGSIZE;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

not even correct, and completely harmless

Thanks for your reply. Maybe a more suitable way of error handling is 'goto err_cancel_table;'?

Yes, but you _most_ provide the detailed analysis of the impact in the commit message for the patches to be considered for merging.

Thanks for the suggestion. The commit message is updated with more details.