mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gve: add missing NULL check for gve_alloc_pending_packet() in TX DQO
@ 2025-06-01 19:34 Alok Tiwari
  2025-06-01 19:49 ` Mina Almasry
  0 siblings, 1 reply; 9+ messages in thread
From: Alok Tiwari @ 2025-06-01 19:34 UTC (permalink / raw)
  To: almasrymina, bcf, joshwash, willemb, pkaligineedi, pabeni, kuba,
	jeroendb, hramamurthy, andrew+netdev, davem, edumazet, netdev
  Cc: alok.a.tiwari, linux-kernel, darren.kenny

gve_alloc_pending_packet() can return NULL, but gve_tx_add_skb_dqo()
did not check for this case before dereferencing the returned pointer.

Add a missing NULL check to prevent a potential NULL pointer
dereference when allocation fails.

This improves robustness in low-memory scenarios.

Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
 drivers/net/ethernet/google/gve/gve_tx_dqo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/google/gve/gve_tx_dqo.c b/drivers/net/ethernet/google/gve/gve_tx_dqo.c
index a27f1574a733..9d705d94b065 100644
--- a/drivers/net/ethernet/google/gve/gve_tx_dqo.c
+++ b/drivers/net/ethernet/google/gve/gve_tx_dqo.c
@@ -764,6 +764,9 @@ static int gve_tx_add_skb_dqo(struct gve_tx_ring *tx,
 	s16 completion_tag;
 
 	pkt = gve_alloc_pending_packet(tx);
+	if (!pkt)
+		return -ENOMEM;
+
 	pkt->skb = skb;
 	completion_tag = pkt - tx->dqo.pending_packets;
 
-- 
2.47.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-06-03 18:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-01 19:34 [PATCH] gve: add missing NULL check for gve_alloc_pending_packet() in TX DQO Alok Tiwari
2025-06-01 19:49 ` Mina Almasry
2025-06-01 19:51   ` [External] : " ALOK TIWARI
2025-06-02  8:50     ` ALOK TIWARI
2025-06-02  9:56       ` Eric Dumazet
2025-06-02 19:24         ` Bailey Forrest
2025-06-03  9:03           ` ALOK TIWARI
2025-06-03 10:50             ` Paolo Abeni
2025-06-03 18:02               ` Bailey Forrest

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®