From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH for-5.0] hw/ppc/e500.c: Handle qemu_find_file() failure
Date: Thu, 26 Mar 2020 11:12:11 +1100 [thread overview]
Message-ID: <20200326001211.GK36889@umbus.fritz.box> (raw)
In-Reply-To: <20200324121216.23899-1-peter.maydell@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]
On Tue, Mar 24, 2020 at 12:12:16PM +0000, Peter Maydell wrote:
> If qemu_find_file() doesn't find the BIOS it returns NULL; we were
> passing that unchecked through to load_elf(), which assumes a non-NULL
> pointer and may misbehave. In practice it fails with a weird message:
>
> $ qemu-system-ppc -M ppce500 -display none -kernel nonesuch
> Bad address
> qemu-system-ppc: could not load firmware '(null)'
>
> Handle the failure case better:
>
> $ qemu-system-ppc -M ppce500 -display none -kernel nonesuch
> qemu-system-ppc: could not find firmware/kernel file 'nonesuch'
>
> Spotted by Coverity (CID 1238954).
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Applied to ppc-for-5.0, thanks.
> ---
> hw/ppc/e500.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index 854cd3ac465..0d1f41197cf 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -1047,6 +1047,10 @@ void ppce500_init(MachineState *machine)
> }
>
> filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, payload_name);
> + if (!filename) {
> + error_report("could not find firmware/kernel file '%s'", payload_name);
> + exit(1);
> + }
>
> payload_size = load_elf(filename, NULL, NULL, NULL,
> &bios_entry, &loadaddr, NULL, NULL,
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2020-03-26 0:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 12:12 [PATCH for-5.0] hw/ppc/e500.c: Handle qemu_find_file() failure Peter Maydell
2020-03-24 12:58 ` Philippe Mathieu-Daudé
2020-03-26 0:12 ` David Gibson [this message]
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=20200326001211.GK36889@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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).