qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer
@ 2016-08-05 10:03 Peter Maydell
  2016-08-05 12:59 ` Fabien Chouteau
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2016-08-05 10:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Fabien Chouteau, Mark Cave-Ayland, Artyom Tarasenko

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()).

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",
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer
  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
  2016-08-08 13:24   ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Fabien Chouteau @ 2016-08-05 12:59 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: patches, Mark Cave-Ayland, Artyom Tarasenko

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",
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/sparc/leon3: Don't call get_image_size() on a NULL pointer
  2016-08-05 12:59 ` Fabien Chouteau
@ 2016-08-08 13:24   ` Peter Maydell
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-08-08 13:24 UTC (permalink / raw)
  To: Fabien Chouteau
  Cc: QEMU Developers, Patch Tracking, Mark Cave-Ayland,
	Artyom Tarasenko

On 5 August 2016 at 13:59, Fabien Chouteau <chouteau@adacore.com> wrote:
> 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; I've applied this patch to master.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-08 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-08-08 13:24   ` Peter Maydell

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).