Skip to contentSkip to conversation

net/ethtool/tunnels: Check return value of nla_nest_start()

PATCH Superseded Li Zhong 1 participant 1 message Sep 18, 2022

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Li Zhong

author
#0 lore raw

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

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

---
 net/ethtool/tunnels.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/tunnels.c +1 -1
index efde33536687..2d6b03a35dd9 100644
@@ -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);
Signature · 1 line
2.25.1