libxl: fix an error path that uses uninitialised rc in libxl_set_memory_target
PATCH 1/1 libxl: fix an error path that uses uninitialised rc in libxl_set_memory_target
ecdc6fd8 ("libxl: Fix libxl_set_memory_target return value") failed to initialised rc in one failure path. Fix it in this path.
Also fixed an indentation issue while I was there.
CID: 1362695
---
Cc: Ian Jackson <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Paulina Szubarczyk <[email protected]>
--- tools/libxl/libxl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/libxl/libxl.c +4 -2
@@ -4927,10 +4927,12 @@ 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_FAIL ; goto out_no_transaction; + } lrc =libxl__fill_dom0_memory_info (gc, ¤t_target_memkb, - ¤t_max_memkb); + ¤t_max_memkb);if (lrc <0 ) { rc =ERROR_FAIL ; goto out_no_transaction; } goto retry_transaction; }else if (!target) {
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Wei Liu writes ("[PATCH] libxl: fix an error path that uses uninitialised rc in libxl_set_memory_target"):
Quoted 4 lines
ecdc6fd8("libxl: Fixlibxl_set_memory_targetreturn value") failed to initialised rc in one failure path. Fix it in this path.Also fixed an indentation issue while I was there.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
tools/libxl/libxl.c retry_transaction: · line 4931
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.06.16 at 16:09, <[email protected]> wrote:
tools/libxl/libxl.c +2
-1@@ -4927,10 +4927,12 @@ 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_FAIL ;
I'm sorry for noticing this only now - is ERROR_FAIL the right thing to use here, considering how things worked before the change that introduced the issue getting fixed here? I had intentionally decided to use ERROR_INVAL in the patch variant I did submit (as at that time I wasn't yet aware of the other fix floating around already).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 12.06.16 at 16:09, <[email protected]> wrote:
tools/libxl/libxl.c +0
-0@@ -4927,10 +4927,12 @@ retry_transaction:
Quoted 12 lines
tools/libxl/libxl.c retry_transaction: · line 4931
Quoted 5 lines
tools/libxl/libxl.c +2
-1target =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_FAIL ;I'm sorry for noticing this only now - is
ERROR_FAILthe right thing to use here, considering how things worked before the change that introduced the issue getting fixed here? I had intentionally decided to useERROR_INVALin the patch variant I did submit (as at that time I wasn't yet aware of the other fix floating around already).
When I wrote this patch, I thought the return value should be tied to xs_transaction_end.
The original implementation could return 1 -- that's not ERROR_INVAL, what did I miss? And the original return value was mad enough anyway so I don't see a need to retain that -- after all the purpose of ecdc6fd8787 is to fix the return value of that function.
Wei.
Quoted 7 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 22.06.16 at 15:47, <[email protected]> wrote:
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 12.06.16 at 16:09, <[email protected]> wrote:
tools/libxl/libxl.c +0
-0@@ -4927,10 +4927,12 @@ retry_transaction:Quoted 12 lines
tools/libxl/libxl.c retry_transaction: · line 4931
Quoted 5 lines
tools/libxl/libxl.c +2
-1target =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_FAIL ;I'm sorry for noticing this only now - is
ERROR_FAILthe right thing to use here, considering how things worked before the change that introduced the issue getting fixed here? I had intentionally decided to useERROR_INVALin the patch variant I did submit (as at that time I wasn't yet aware of the other fix floating around already).
Quoted 2 lines
When I wrote this patch, I thought the return value should be tied to
xs_transaction_end.
xs_transaction_end() returning zero means success afaict.
Quoted 4 lines
The original implementation could return 1 -- that's not
ERROR_INVAL, what did I miss? And the original return value was mad enough anyway so I don't see a need to retain that -- after all the purpose ofecdc6fd8787is to fix the return value of that function.
I didn't mean to return to that crude model. It is my understanding that the original meaning of 1 was "invalid" (and would have resulted when going through the path in question), and hence ERROR_INVAL would be the proper replacement for the case where target and/or domid aren't valid.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 22.06.16 at 15:47, <[email protected]> wrote:
Quoted 17 lines · Jan Beulich
tools/libxl/libxl.c retry_transaction: · line 4931
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 12.06.16 at 16:09, <[email protected]> wrote:
tools/libxl/libxl.c +2
-1@@ -4927,10 +4927,12 @@ 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_FAIL ;I'm sorry for noticing this only now - is
ERROR_FAILthe right thing to use here, considering how things worked before the change that introduced the issue getting fixed here? I had intentionally decided to useERROR_INVALin the patch variant I did submit (as at that time I wasn't yet aware of the other fix floating around already).
Quoted 5 lines
Quoted 2 lines
When I wrote this patch, I thought the return value should be tied to
xs_transaction_end.
xs_transaction_end()returning zero means success afaict.
/* End a transaction.
* If abandon is true, transaction is discarded instead of committed.
* Returns false on failure: if errno == EAGAIN, you have to restart
* transaction.
*/
bool xs_transaction_end(struct xs_handle *h, xs_transaction_t t,
bool abort);
I think you misread.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 22.06.16 at 15:59, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 22.06.16 at 15:47, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
tools/libxl/libxl.c retry_transaction: · line 4928
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 12.06.16 at 16:09, <[email protected]> wrote:
tools/libxl/libxl.c +0
-0@@ -4927,10 +4927,12 @@ retry_transaction: target = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target",dompath));
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
tools/libxl/libxl.c retry_transaction: · line 4931
Quoted 4 lines
tools/libxl/libxl.c +2
-1if (!target && !domid) { -if (!xs_transaction_end (ctx->xsh, t,1 )) +if (!xs_transaction_end (ctx->xsh, t,1 )) { + rc =ERROR_FAIL ;I'm sorry for noticing this only now - is
ERROR_FAILthe right thing to use here, considering how things worked before the change that introduced the issue getting fixed here? I had intentionally decided to useERROR_INVALin the patch variant I did submit (as at that time I wasn't yet aware of the other fix floating around already).Quoted 5 lines
Quoted 2 lines
When I wrote this patch, I thought the return value should be tied to
xs_transaction_end.
xs_transaction_end()returning zero means success afaict./* End a transaction.
* If abandon is true, transaction is discarded instead of committed.
* Returns false on failure: if errno == EAGAIN, you have to restart
* transaction.
*/
bool xs_transaction_end(structxs_handle*h,xs_transaction_tt,
Quoted 3 lines
bool abort);I think you misread.
Indeed, I got mislead by "goto out_no_transaction". Yet that doesn't change the discussion of the error - originally this didn't return -1 here, but +1 (i.e. reflecting the surrounding if(), not the inner one).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 37 lines · Jan Beulich
Quoted 37 lines
Quoted 1 line
Quoted 1 line · On 22.06.16 at 15:59, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 22.06.16 at 15:47, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
tools/libxl/libxl.c retry_transaction: · line 4928
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 12.06.16 at 16:09, <[email protected]> wrote:
tools/libxl/libxl.c +0
-0@@ -4927,10 +4927,12 @@ retry_transaction: target = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target",dompath));
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
tools/libxl/libxl.c retry_transaction: · line 4931
Quoted 4 lines
tools/libxl/libxl.c +2
-1if (!target && !domid) { -if (!xs_transaction_end (ctx->xsh, t,1 )) +if (!xs_transaction_end (ctx->xsh, t,1 )) { + rc =ERROR_FAIL ;I'm sorry for noticing this only now - is
ERROR_FAILthe right thing to use here, considering how things worked before the change that introduced the issue getting fixed here? I had intentionally decided to useERROR_INVALin the patch variant I did submit (as at that time I wasn't yet aware of the other fix floating around already).Quoted 5 lines
Quoted 2 lines
When I wrote this patch, I thought the return value should be tied to
xs_transaction_end.
xs_transaction_end()returning zero means success afaict./* End a transaction.
* If abandon is true, transaction is discarded instead of committed.
* Returns false on failure: if errno == EAGAIN, you have to restart
* transaction.
*/
bool xs_transaction_end(structxs_handle*h,xs_transaction_tt,bool abort);
Quoted 7 lines
Quoted 1 line
I think you misread.
Indeed, I got mislead by "goto
out_no_transaction". Yet that doesn't change the discussion of the error - originally this didn't return -1 here, but +1 (i.e. reflecting the surroundingif(), not the inner one).
So that comes back to the intent of ecdc6fd8 -- to fix the mad semantics of that function. We don't need to duplicate what it did before.
Wei.
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel