From: Ameer Hamza <amhamza.mgc@gmail.com>
To: jeroendb@google.com, csully@google.com, awogbemila@google.com,
davem@davemloft.net, kuba@kernel.org, bcf@google.com,
willemb@google.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
amhamza.mgc@gmail.com
Subject: [PATCH] gve: fix for null pointer dereference.
Date: Sun, 5 Dec 2021 23:33:16 +0500 [thread overview]
Message-ID: <20211205183316.7800-1-amhamza.mgc@gmail.com> (raw)
Avoid passing NULL skb to __skb_put() function call if
napi_alloc_skb() returns NULL.
Addresses-Coverity: 1494144 (Dereference NULL return value)
Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
drivers/net/ethernet/google/gve/gve_utils.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/google/gve/gve_utils.c b/drivers/net/ethernet/google/gve/gve_utils.c
index 88ca49cbc1e2..f4befdb54ad4 100644
--- a/drivers/net/ethernet/google/gve/gve_utils.c
+++ b/drivers/net/ethernet/google/gve/gve_utils.c
@@ -68,6 +68,9 @@ struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *napi,
set_protocol = ctx->curr_frag_cnt == ctx->expected_frag_cnt - 1;
} else {
skb = napi_alloc_skb(napi, len);
+
+ if (unlikely(!ctx->skb_head))
+ return NULL;
set_protocol = true;
}
__skb_put(skb, len);
--
2.25.1
next reply other threads:[~2021-12-05 18:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-05 18:33 Ameer Hamza [this message]
2021-12-05 18:38 ` [PATCH v2] gve: fix for null pointer dereference Ameer Hamza
2021-12-08 5:10 ` patchwork-bot+netdevbpf
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=20211205183316.7800-1-amhamza.mgc@gmail.com \
--to=amhamza.mgc@gmail.com \
--cc=awogbemila@google.com \
--cc=bcf@google.com \
--cc=csully@google.com \
--cc=davem@davemloft.net \
--cc=jeroendb@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).