qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fabien Chouteau <chouteau@adacore.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: patches@linaro.org,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Artyom Tarasenko <atar4qemu@gmail.com>
Subject: Re: [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer
Date: Fri, 5 Aug 2016 14:59:37 +0200	[thread overview]
Message-ID: <57A48DB9.8000008@adacore.com> (raw)
In-Reply-To: <1470391439-28427-1-git-send-email-peter.maydell@linaro.org>

On 08/05/2016 12:03 PM, Peter Maydell wrote:
> get_image_size() doesn't handle being passed a NULL pointer, so
> avoid doing that. Spotted by the clang ub sanitizer (which notices
> the attempt to pass NULL to open()).
> 

Looks good.

Thanks Peter!

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/sparc/leon3.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
> index dbae41f..6e16478 100644
> --- a/hw/sparc/leon3.c
> +++ b/hw/sparc/leon3.c
> @@ -171,7 +171,11 @@ static void leon3_generic_hw_init(MachineState *machine)
>      }
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>  
> -    bios_size = get_image_size(filename);
> +    if (filename) {
> +        bios_size = get_image_size(filename);
> +    } else {
> +        bios_size = -1;
> +    }
>  
>      if (bios_size > prom_size) {
>          fprintf(stderr, "qemu: could not load prom '%s': file too big\n",
> 

  reply	other threads:[~2016-08-05 13:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 10:03 [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer Peter Maydell
2016-08-05 12:59 ` Fabien Chouteau [this message]
2016-08-08 13:24   ` Peter Maydell

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=57A48DB9.8000008@adacore.com \
    --to=chouteau@adacore.com \
    --cc=atar4qemu@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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).