Skip to contentSkip to conversation

libxl: don't leave libxl_set_memory_target() return value uninitialized

PATCH In review Jan Beulich 2 participants 2 messages Jun 20, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: don't leave libxl_set_memory_target() return value uninitialized

Commit ecdc6fd878 ("libxl: Fix libxl_set_memory_target return value") deliberately made rc an uninitialized variable, but left a code path in place where the variable doesn't get initialized. Use ERROR_INVAL in this case to match behavior prior to that patch; arguably ERROR_FAIL might be more appropriate.

---
Did Coverity not spot this yet?

tools/libxl/libxl.c +3 -1
@@ -4927,8 +4927,10 @@ retry_transaction:
 
     target = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target", dompath));
     if (!target && !domid) {
-        if (!xs_transaction_end(ctx->xsh, t, 1))
+        if (!xs_transaction_end(ctx->xsh, t, 1)) {
+            rc = ERROR_INVAL;
             goto out_no_transaction;
+        }
         lrc = libxl__fill_dom0_memory_info(gc, &current_target_memkb,
                                           &current_max_memkb);
         if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }

libxl: don't leave libxl_set_memory_target() return value uninitialized

Commit ecdc6fd878 ("libxl: Fix libxl_set_memory_target return value") deliberately made rc an uninitialized variable, but left a code path in place where the variable doesn't get initialized. Use ERROR_INVAL in this case to match behavior prior to that patch; arguably ERROR_FAIL might be more appropriate.

---
Did Coverity not spot this yet?

tools/libxl/libxl.c +3 -1
@@ -4927,8 +4927,10 @@ retry_transaction:
 
     target = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target", dompath));
     if (!target && !domid) {
-        if (!xs_transaction_end(ctx->xsh, t, 1))
+        if (!xs_transaction_end(ctx->xsh, t, 1)) {
+            rc = ERROR_INVAL;
             goto out_no_transaction;
+        }
         lrc = libxl__fill_dom0_memory_info(gc, &current_target_memkb,
                                           &current_max_memkb);
         if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 10 lines · Jan Beulich

Commit ecdc6fd878 ("libxl: Fix libxl_set_memory_target return value") deliberately made rc an uninitialized variable, but left a code path in place where the variable doesn't get initialized. Use ERROR_INVAL in this case to match behavior prior to that patch; arguably ERROR_FAIL might be more appropriate.

---
Did Coverity not spot this yet?

Yes, I already sent a patch. But no-one reviewed it yet... :-/

<[email protected]>

Quoted 34 lines
tools/libxl/libxl.c +3 -1
@@ -4927,8 +4927,10 @@ retry_transaction:
 
     target = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target", dompath));
     if (!target && !domid) {
-        if (!xs_transaction_end(ctx->xsh, t, 1))
+        if (!xs_transaction_end(ctx->xsh, t, 1)) {
+            rc = ERROR_INVAL;
             goto out_no_transaction;
+        }
         lrc = libxl__fill_dom0_memory_info(gc, &current_target_memkb,
                                           &current_max_memkb);
         if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }

libxl: don't leave libxl_set_memory_target() return value uninitialized

Commit ecdc6fd878 ("libxl: Fix libxl_set_memory_target return value") deliberately made rc an uninitialized variable, but left a code path in place where the variable doesn't get initialized. Use ERROR_INVAL in this case to match behavior prior to that patch; arguably ERROR_FAIL might be more appropriate.

---
Did Coverity not spot this yet?

tools/libxl/libxl.c +0 -0
@@ -4927,8 +4927,10 @@ retry_transaction:
 

tools/libxl/libxl.c retry_transaction: · line 4936

Quoted 10 lines
tools/libxl/libxl.c +3 -1
     target = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target", dompath));
     if (!target && !domid) {
-        if (!xs_transaction_end(ctx->xsh, t, 1))
+        if (!xs_transaction_end(ctx->xsh, t, 1)) {
+            rc = ERROR_INVAL;
             goto out_no_transaction;
+        }
         lrc = libxl__fill_dom0_memory_info(gc, &current_target_memkb,
                                           &current_max_memkb);
         if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel