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
State New
Headers show
Series Add check for nla_nest_start() | expand

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(+)
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) ||