[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Avoid dereferencing NULL cache objects.



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@xxxxxxxxx>
---
 src/xenvif/receiver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xenvif/receiver.c b/src/xenvif/receiver.c
index 4807582..0ce5b67 100644
--- a/src/xenvif/receiver.c
+++ b/src/xenvif/receiver.c
@@ -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;
 }
 
-- 
2.41.0.windows.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.