netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] net/ethtool/tunnels: check the return value of nla_nest_start()
@ 2022-09-21  8:30 Li Zhong
  2022-09-21 13:07 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Li Zhong @ 2022-09-21  8:30 UTC (permalink / raw)
  To: netdev; +Cc: pabeni, kuba, edumazet, davem, Li Zhong

Check the return value of nla_nest_start(). When starting the entry
level nested attributes, if the tailroom of socket buffer is
insufficient to store the attribute header and payload, the return value
will be NULL and we should check it. If it is NULL, go to the
error_cancel_entry label to do error handling.

v2: error handling jump to error_cancel_entry, more details in commit 
meesage

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 net/ethtool/tunnels.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ethtool/tunnels.c b/net/ethtool/tunnels.c
index efde33536687..67fb414ca859 100644
--- a/net/ethtool/tunnels.c
+++ b/net/ethtool/tunnels.c
@@ -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)
+			goto err_cancel_entry;
 
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 htons(IANA_VXLAN_UDP_PORT)) ||
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-21 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-21  8:30 [PATCH net-next v2] net/ethtool/tunnels: check the return value of nla_nest_start() Li Zhong
2022-09-21 13:07 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).