From: "Jan Beulich" Subject: [PATCH] libxl: don't leave libxl_set_memory_target() return value uninitialized Date: Mon, 20 Jun 2016 04:06:16 -0600 Message-ID: <5767DC3802000078000F6930@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part90A6AD08.2__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEw62-0008Nn-Hl for xen-devel@lists.xenproject.org; Mon, 20 Jun 2016 10:06:22 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: George Dunlap , Ian Jackson , Wei Liu List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part90A6AD08.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 --- Did Coverity not spot this yet? --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -4927,8 +4927,10 @@ retry_transaction: =20 target =3D 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 =3D ERROR_INVAL; goto out_no_transaction; + } lrc =3D libxl__fill_dom0_memory_info(gc, ¤t_target_memkb, ¤t_max_memkb); if (lrc < 0) { rc =3D ERROR_FAIL; goto out_no_transaction; } --=__Part90A6AD08.2__= Content-Type: text/plain; name="libxl-set_memory_target-return.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="libxl-set_memory_target-return.patch" libxl: don't leave libxl_set_memory_target() return value uninitialized=0A= =0ACommit ecdc6fd878 ("libxl: Fix libxl_set_memory_target return value")=0A= deliberately made rc an uninitialized variable, but left a code path = in=0Aplace where the variable doesn't get initialized. Use ERROR_INVAL = in=0Athis case to match behavior prior to that patch; arguably ERROR_FAIL= =0Amight be more appropriate.=0A=0ASigned-off-by: Jan Beulich =0A---=0ADid Coverity not spot this yet?=0A=0A--- a/tools/libxl/libxl= .c=0A+++ b/tools/libxl/libxl.c=0A@@ -4927,8 +4927,10 @@ retry_transaction:= =0A =0A target =3D libxl__xs_read(gc, t, GCSPRINTF("%s/memory/target", = dompath));=0A if (!target && !domid) {=0A- if (!xs_transaction_e= nd(ctx->xsh, t, 1))=0A+ if (!xs_transaction_end(ctx->xsh, t, 1)) = {=0A+ rc =3D ERROR_INVAL;=0A goto out_no_transaction= ;=0A+ }=0A lrc =3D libxl__fill_dom0_memory_info(gc, = ¤t_target_memkb,=0A = ¤t_max_memkb);=0A if (lrc < 0) { rc =3D ERROR_FAIL; goto = out_no_transaction; }=0A --=__Part90A6AD08.2__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__Part90A6AD08.2__=--