From: Simon Gaiser <simon@invisiblethingslab.com>
To: xen-devel@lists.xenproject.org
Cc: "Simon Gaiser" <simon@invisiblethingslab.com>,
"Wei Liu" <wei.liu2@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 1/3] libxc: Cleanup xc_dom_parse_elf_kernel()'s return value
Date: Thu, 8 Feb 2018 22:49:08 +0100 [thread overview]
Message-ID: <20180208214910.10699-2-simon@invisiblethingslab.com> (raw)
In-Reply-To: <20180208214910.10699-1-simon@invisiblethingslab.com>
xc_dom_loader.parser() should return elf_negerrnoval.
Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
---
tools/libxc/xc_dom_elfloader.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xc_dom_elfloader.c
index 568d7f370c..c936f92a66 100644
--- a/tools/libxc/xc_dom_elfloader.c
+++ b/tools/libxc/xc_dom_elfloader.c
@@ -140,14 +140,10 @@ static elf_negerrnoval xc_dom_probe_elf_kernel(struct xc_dom_image *dom)
return 0;
}
-static elf_errorstatus xc_dom_parse_elf_kernel(struct xc_dom_image *dom)
- /*
- * This function sometimes returns -1 for error and sometimes
- * an errno value. ?!?!
- */
+static elf_negerrnoval xc_dom_parse_elf_kernel(struct xc_dom_image *dom)
{
struct elf_binary *elf;
- elf_errorstatus rc;
+ elf_negerrnoval rc;
rc = check_elf_kernel(dom, 1);
if ( rc != 0 )
@@ -155,9 +151,9 @@ static elf_errorstatus xc_dom_parse_elf_kernel(struct xc_dom_image *dom)
elf = xc_dom_malloc(dom, sizeof(*elf));
if ( elf == NULL )
- return -1;
+ return -ENOMEM;
dom->private_loader = elf;
- rc = elf_init(elf, dom->kernel_blob, dom->kernel_size);
+ rc = elf_init(elf, dom->kernel_blob, dom->kernel_size) != 0 ? -EINVAL : 0;
xc_elf_set_logfile(dom->xch, elf, 1);
if ( rc != 0 )
{
@@ -177,8 +173,9 @@ static elf_errorstatus xc_dom_parse_elf_kernel(struct xc_dom_image *dom)
/* parse binary and get xen meta info */
elf_parse_binary(elf);
- if ( (rc = elf_xen_parse(elf, &dom->parms)) != 0 )
+ if ( elf_xen_parse(elf, &dom->parms) != 0 )
{
+ rc = -EINVAL;
goto out;
}
--
2.15.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-02-08 21:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-08 21:49 libx[lc]: Improve error reporting for invalid kernel images Simon Gaiser
2018-02-08 21:49 ` Simon Gaiser [this message]
2018-02-09 12:00 ` [PATCH 1/3] libxc: Cleanup xc_dom_parse_elf_kernel()'s return value Roger Pau Monné
2018-02-08 21:49 ` [PATCH 2/3] libxl: Improve logging in libxl__build_dom() Simon Gaiser
2018-02-09 12:08 ` Roger Pau Monné
2018-02-08 21:49 ` [PATCH 3/3] libxc: xc_dom_parse_elf_kernel: Return error for invalid kernel images Simon Gaiser
2018-02-09 12:19 ` Roger Pau Monné
2018-02-12 14:51 ` libx[lc]: Improve error reporting " Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180208214910.10699-2-simon@invisiblethingslab.com \
--to=simon@invisiblethingslab.com \
--cc=ian.jackson@eu.citrix.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).