mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] net/ethtool/tunnels: Check return value of nla_nest_start()
@ 2022-09-18  1:54 Li Zhong
  0 siblings, 0 replies; only message in thread
From: Li Zhong @ 2022-09-18  1:54 UTC (permalink / raw)
  To: linux-kernel, netdev; +Cc: pabeni, kuba, edumazet, davem, Li Zhong

Return value of nla_nest_start() could be null on error. We need to
check it before we pass entry to nla_nest_end().

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

diff --git a/net/ethtool/tunnels.c b/net/ethtool/tunnels.c
index efde33536687..2d6b03a35dd9 100644
--- a/net/ethtool/tunnels.c
+++ b/net/ethtool/tunnels.c
@@ -140,7 +140,7 @@ ethnl_tunnel_info_fill_reply(const struct ethnl_req_info *req_base,
 		if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
 				 htons(IANA_VXLAN_UDP_PORT)) ||
 		    nla_put_u32(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE,
-				ilog2(UDP_TUNNEL_TYPE_VXLAN)))
+				ilog2(UDP_TUNNEL_TYPE_VXLAN)) || !entry)
 			goto err_cancel_entry;
 
 		nla_nest_end(skb, entry);
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-18  1:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-18  1:54 [PATCH v1] net/ethtool/tunnels: Check return value of nla_nest_start() Li Zhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®