[ovs-dev] [PATCH] datapath-windows: Handle memory allocation failure for event creation

Sairam Venugopal vsairam at vmware.com
Tue Jun 21 23:54:02 UTC 2016


Release the lock and return if an event entry fails to get allocated.

Signed-off-by: Sairam Venugopal <vsairam at vmware.com>
---
 datapath-windows/ovsext/Event.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/datapath-windows/ovsext/Event.c b/datapath-windows/ovsext/Event.c
index abf8f0d..f9bea7f 100644
--- a/datapath-windows/ovsext/Event.c
+++ b/datapath-windows/ovsext/Event.c
@@ -134,6 +134,13 @@ OvsPostEvent(POVS_EVENT_ENTRY event)
 
         elem = (POVS_EVENT_QUEUE_ELEM)OvsAllocateMemoryWithTag(
             sizeof(*elem), OVS_EVENT_POOL_TAG);
+
+        if (elem == NULL) {
+            OVS_LOG_WARN("Fail to allocate memory for event");
+            OvsReleaseEventQueueLock();
+            return;
+        }
+
         RtlCopyMemory(&elem->event, event, sizeof elem->event);
         InsertTailList(&queue->elemList, &elem->link);
         queue->numElems++;
-- 
2.5.0.windows.1




More information about the dev mailing list