]> xenbits.xensource.com Git - pvdrivers/win/xenvif.git/commitdiff
Avoid dereferencing NULL cache objects.
authorOwen Smith <owen.smith@cloud.com>
Tue, 22 Aug 2023 11:28:45 +0000 (12:28 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Tue, 12 Sep 2023 08:24:57 +0000 (10:24 +0200)
XENBUS_CACHE(Get, ...) can fail in low memory conditions. Avoid dereferencing
NULL pointers in ASSERTs
Fix up error path to avoid returning a NULL pointer to the cache.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
src/xenvif/receiver.c

index 48075824d15f088b8cc8def18b9a901dafdf266b..0ce5b67782d0f399a6e7811656ceb595dc1631fd 100644 (file)
@@ -266,6 +266,8 @@ __ReceiverRingGetPacket(
                           &Receiver->CacheInterface,
                           Ring->PacketCache,
                           Locked);
+    if (Packet == NULL)
+        return NULL;
 
     ASSERT(IsZeroMemory(&Packet->Info, sizeof (XENVIF_PACKET_INFO)));
     ASSERT3P(Packet->Ring, ==, Ring);
@@ -1788,11 +1790,11 @@ __ReceiverRingPreparePacket(
 fail2:
     Error("fail2\n");
 
+    __ReceiverRingPutFragment(Ring, Fragment);
+
 fail1:
     Error("fail1 (%08x)\n", status);
 
-    __ReceiverRingPutFragment(Ring, Fragment);
-    
     return NULL;
 }