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, yoshfuji@linux-ipv6.org, dsahern@kernel.org,
Li Zhong <floridsleeves@gmail.com>
Subject: [PATCH v1] net/ipv4/nexthop: check the return value of nexthop_find_by_id()
Date: Fri, 16 Sep 2022 19:30:20 -0700 [thread overview]
Message-ID: <20220917023020.3845137-1-floridsleeves@gmail.com> (raw)
Check the return value of nexthop_find_by_id(), which could be NULL on
when not found. So we check to avoid null pointer dereference.
Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
net/ipv4/nexthop.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 853a75a8fbaf..9f91bb78eed5 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -2445,6 +2445,10 @@ static struct nexthop *nexthop_create_group(struct net *net,
struct nh_info *nhi;
nhe = nexthop_find_by_id(net, entry[i].id);
+ if (!nhe) {
+ err = -EINVAL;
+ goto out_no_nh;
+ }
if (!nexthop_get(nhe)) {
err = -ENOENT;
goto out_no_nh;
--
2.25.1
next reply other threads:[~2022-09-17 2:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-17 2:30 Li Zhong [this message]
2022-09-17 8:29 ` [PATCH v1] net/ipv4/nexthop: check the return value of nexthop_find_by_id() Nikolay Aleksandrov
2022-09-17 14:46 ` David Ahern
2022-09-18 1:54 ` Li Zhong
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=20220917023020.3845137-1-floridsleeves@gmail.com \
--to=floridsleeves@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yoshfuji@linux-ipv6.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.