]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gve: add missing NULL check for gve_alloc_pending_packet() in TX DQO
authorAlok Tiwari <alok.a.tiwari@oracle.com>
Mon, 2 Jun 2025 10:34:29 +0000 (03:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Jun 2025 11:06:13 +0000 (12:06 +0100)
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.

Fixes: a57e5de476be ("gve: DQO: Add TX path")
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/google/gve/gve_tx_dqo.c

index a27f1574a733704b1f78e73133a9cec301993038..9d705d94b065212a0549f335680e428da6271088 100644 (file)
@@ -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;