* [PATCH] libxl: don't leave libxl_set_memory_target() return value uninitialized
@ 2016-06-20 10:06 Jan Beulich
2016-06-20 10:08 ` Wei Liu
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2016-06-20 10:06 UTC (permalink / raw)
To: xen-devel; +Cc: George Dunlap, Ian Jackson, Wei Liu
[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]
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.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Did Coverity not spot this yet?
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -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, ¤t_target_memkb,
¤t_max_memkb);
if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }
[-- Attachment #2: libxl-set_memory_target-return.patch --]
[-- Type: text/plain, Size: 1079 bytes --]
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.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Did Coverity not spot this yet?
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -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, ¤t_target_memkb,
¤t_max_memkb);
if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libxl: don't leave libxl_set_memory_target() return value uninitialized
2016-06-20 10:06 [PATCH] libxl: don't leave libxl_set_memory_target() return value uninitialized Jan Beulich
@ 2016-06-20 10:08 ` Wei Liu
0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2016-06-20 10:08 UTC (permalink / raw)
To: Jan Beulich; +Cc: George Dunlap, xen-devel, Wei Liu, Ian Jackson
On Mon, Jun 20, 2016 at 04:06:16AM -0600, Jan Beulich wrote:
> 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.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> Did Coverity not spot this yet?
>
Yes, I already sent a patch. But no-one reviewed it yet... :-/
<1465740590-21337-1-git-send-email-wei.liu2@citrix.com>
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -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, ¤t_target_memkb,
> ¤t_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.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> Did Coverity not spot this yet?
>
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -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, ¤t_target_memkb,
> ¤t_max_memkb);
> if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-20 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20 10:06 [PATCH] libxl: don't leave libxl_set_memory_target() return value uninitialized Jan Beulich
2016-06-20 10:08 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).