[ovs-dev] [PATCH] datapath-windows: Handle possible NULL pointer dereference in STT

Paul Boca pboca at cloudbasesolutions.com
Tue Jun 14 11:26:41 UTC 2016


Check if OvsAllocatememoryWithTag succeeded or not.
In case of failure propagate cleanup and return.

Signed-off-by: Paul-Daniel Boca <pboca at cloudbasesolutions.com>
---
 datapath-windows/ovsext/Stt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/datapath-windows/ovsext/Stt.c b/datapath-windows/ovsext/Stt.c
index 0bac5f2..e63211d 100644
--- a/datapath-windows/ovsext/Stt.c
+++ b/datapath-windows/ovsext/Stt.c
@@ -641,6 +641,9 @@ OvsSttReassemble(POVS_SWITCH_CONTEXT switchContext,
         POVS_STT_PKT_ENTRY entry;
         entry = OvsAllocateMemoryWithTag(sizeof(OVS_STT_PKT_ENTRY),
                                          OVS_STT_POOL_TAG);
+        if (NULL == entry) {
+            goto handle_error;
+        }
         RtlZeroMemory(entry, sizeof (OVS_STT_PKT_ENTRY));
 
         /* Update Key, timestamp and recvdLen */
@@ -663,6 +666,10 @@ OvsSttReassemble(POVS_SWITCH_CONTEXT switchContext,
         entry->allocatedLen = innerPacketLen;
         entry->packetBuf = OvsAllocateMemoryWithTag(innerPacketLen,
                                                     OVS_STT_POOL_TAG);
+        if (NULL == entry->packetBuf) {
+            OvsFreeMemoryWithTag(pktFragEntry, OVS_STT_POOL_TAG);
+            goto handle_error;
+        }
         if (OvsGetPacketBytes(curNbl, fragmentLength, startOffset,
                               entry->packetBuf + offset) == NULL) {
             OVS_LOG_ERROR("Error when obtaining bytes from Packet");
-- 
2.7.2.windows.1



More information about the dev mailing list