mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Li Zhong <floridsleeves@gmail.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
	davem@davemloft.net, Li Zhong <floridsleeves@gmail.com>
Subject: [PATCH v1] net/ethtool/tunnels: Check return value of nla_nest_start()
Date: Sat, 17 Sep 2022 18:54:54 -0700	[thread overview]
Message-ID: <20220918015454.672485-1-floridsleeves@gmail.com> (raw)

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


                 reply	other threads:[~2022-09-18  1:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220918015454.672485-1-floridsleeves@gmail.com \
    --to=floridsleeves@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®