Skip to contentSkip to conversation

gve: fix for null pointer dereference.

PATCH Superseded Ameer Hamza 2 participants 3 messages Dec 5, 2021 – Dec 8, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gve: fix for null pointer dereference.

Avoid passing NULL skb to __skb_put() function call if napi_alloc_skb() returns NULL.

Addresses-Coverity: 1494144 (Dereference NULL return value)

---
 drivers/net/ethernet/google/gve/gve_utils.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/google/gve/gve_utils.c +3 -0
index 88ca49cbc1e2..f4befdb54ad4 100644
@@ -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);
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 gve: fix for null pointer dereference.

Avoid passing NULL skb to __skb_put() function call if napi_alloc_skb() returns NULL.

Addresses-Coverity: 1494144 (Dereference NULL return value)

---
Change in v2:
checking for correct skb pointer for NULL check

---
 drivers/net/ethernet/google/gve/gve_utils.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/google/gve/gve_utils.c +3 -0
index 88ca49cbc1e2..d57508bc4307 100644
@@ -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(!skb))
+			return NULL;
 		set_protocol = true;
 	}
 	__skb_put(skb, len);
Signature · 1 line
2.25.1
#2 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Sun, 5 Dec 2021 23:38:10 +0500 you wrote:

Avoid passing NULL skb to __skb_put() function call if napi_alloc_skb() returns NULL.

Addresses-Coverity: 1494144 (Dereference NULL return value)

[...]

Here is the summary with links:
- [v2] gve: fix for null pointer dereference.

    https://git.kernel.org/netdev/net/c/e6f60c51f043

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html