[prev in list] [next in list] [prev in thread] [next in thread] 

List:       win-pv-devel
Subject:    [PATCH] Fix ASSERT failures in error paths
From:       Owen Smith <owen.smith () citrix ! com>
Date:       2023-01-30 14:42:19
Message-ID: 20230130144219.4056593-1-owen.smith () citrix ! com
[Download RAW message or body]

* StorePrepareRequest can fail if a non-NULL transaction is passed.
  Check the return value where a transaction is passed to StorePrepareRequest
* StoreSubmitRequest should zero the request if it fails.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
---
 src/xenbus/store.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/xenbus/store.c b/src/xenbus/store.c
index 5ffea1f..778414c 100644
--- a/src/xenbus/store.c
+++ b/src/xenbus/store.c
@@ -966,6 +966,8 @@ StoreSubmitRequest(
 fail1:
     Error("fail1 (%08x)\n", status);
 
+    RtlZeroMemory(Request, sizeof (XENBUS_STORE_REQUEST));
+
     return NULL;
 }
 
@@ -1571,17 +1573,18 @@ StoreTransactionEnd(
                                  XS_TRANSACTION_END,
                                  (Commit) ? "T" : "F", 2,
                                  NULL, 0);
-    ASSERT(NT_SUCCESS(status));
+    if (!NT_SUCCESS(status))
+        goto fail1;
 
     Response = StoreSubmitRequest(Context, &Request);
 
     status = STATUS_NO_MEMORY;
     if (Response == NULL)
-        goto fail1;
+        goto fail2;
 
     status = StoreCheckResponse(Response);
     if (!NT_SUCCESS(status) && status != STATUS_RETRY)
-        goto fail2;
+        goto fail3;
 
     StoreFreeResponse(Response);
     ASSERT(IsZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST)));
@@ -1605,11 +1608,13 @@ done:
 
     return status;
 
-fail2:
+fail3:
     ASSERT3U(status, !=, STATUS_RETRY);
 
     StoreFreeResponse(Response);
 
+fail2:
+
 fail1:
     ASSERT(IsZeroMemory(&Request, sizeof (XENBUS_STORE_REQUEST)));
 
-- 
2.39.0.windows.1


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic