From: Li Zhong Date: Wed, 21 Sep 2022 18:17:16 +0000 (-0700) Subject: ethtool: tunnels: check the return value of nla_nest_start() X-Git-Tag: v6.1-rc1~170^2~125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=05cd823863fd32e9fcd5e8818a0a9070e54cfcc1;p=thirdparty%2Fkernel%2Flinux.git ethtool: tunnels: check the return value of nla_nest_start() 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. There is, however, no real bug here since if the skb is full nla_put_be16() will fail as well and we'll error out. Signed-off-by: Li Zhong Link: https://lore.kernel.org/r/20220921181716.1629541-1-floridsleeves@gmail.com Signed-off-by: Jakub Kicinski --- diff --git a/net/ethtool/tunnels.c b/net/ethtool/tunnels.c index efde335366873..67fb414ca859b 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)) ||