summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Can <yuancan@huawei.com>2022-11-29 02:39:34 +0100
committerJakub Kicinski <kuba@kernel.org>2022-11-29 17:44:24 +0100
commit7a945ce0c19bbdf821d5f7ce1515e7fb8e444465 (patch)
treec73ac81f7f64668556960d25b6e4d2ea880d942a
parentnfp: ethtool: support reporting link modes (diff)
downloadlinux-7a945ce0c19bbdf821d5f7ce1515e7fb8e444465.tar.xz
linux-7a945ce0c19bbdf821d5f7ce1515e7fb8e444465.zip
udp_tunnel: Add checks for nla_nest_start() in __udp_tunnel_nic_dump_write()
As the nla_nest_start() may fail with NULL returned, the return value should be checked. Note that this is not a real bug, nothing will break here. The next nla_put() will fail as well and we'll bail (and nla_nest_cancel() can handle NULL). But we keep getting those "fixes" so whatever. Signed-off-by: Yuan Can <yuancan@huawei.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20221129013934.55184-1-yuancan@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/ipv4/udp_tunnel_nic.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
index bc3a043a5d5c..029219749785 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)
+ return -EMSGSIZE;
if (nla_put_be16(skb, ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT,
utn->entries[table][j].port) ||