qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-trivial] [Qemu-devel] [PATCH] hw/core/generic-loader: Fix crash when running without CPU
       [not found] <1485377117-18105-1-git-send-email-thuth@redhat.com>
@ 2017-02-27 19:36 ` Thomas Huth
  2017-04-23 17:34   ` [Qemu-trivial] " Michael Tokarev
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2017-02-27 19:36 UTC (permalink / raw)
  To: qemu-devel, Alistair Francis; +Cc: Laurent Vivier, QEMU Trivial

On 25.01.2017 21:45, Thomas Huth wrote:
> When running QEMU with "-M none -device loader,file=kernel.elf", it
> currently crashes with a segmentation fault, because the "none"-machine
> does not have any CPU by default and the generic loader code tries
> to dereference s->cpu. Fix it by adding an appropriate check for a
> NULL pointer.
> 
> Reported-by: Laurent Vivier <laurent@vivier.eu>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/core/generic-loader.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
> index 58f1f02..4601267 100644
> --- a/hw/core/generic-loader.c
> +++ b/hw/core/generic-loader.c
> @@ -137,20 +137,21 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)
>  #endif
>  
>      if (s->file) {
> +        AddressSpace *as = s->cpu ? s->cpu->as :  NULL;
> +
>          if (!s->force_raw) {
>              size = load_elf_as(s->file, NULL, NULL, &entry, NULL, NULL,
> -                               big_endian, 0, 0, 0, s->cpu->as);
> +                               big_endian, 0, 0, 0, as);
>  
>              if (size < 0) {
>                  size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL,
> -                                      s->cpu->as);
> +                                      as);
>              }
>          }
>  
>          if (size < 0 || s->force_raw) {
>              /* Default to the maximum size being the machine's ram size */
> -            size = load_image_targphys_as(s->file, s->addr, ram_size,
> -                                          s->cpu->as);
> +            size = load_image_targphys_as(s->file, s->addr, ram_size, as);
>          } else {
>              s->addr = entry;
>          }

Ping?

 Thomas



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

* Re: [Qemu-trivial] [PATCH] hw/core/generic-loader: Fix crash when running without CPU
  2017-02-27 19:36 ` [Qemu-trivial] [Qemu-devel] [PATCH] hw/core/generic-loader: Fix crash when running without CPU Thomas Huth
@ 2017-04-23 17:34   ` Michael Tokarev
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Tokarev @ 2017-04-23 17:34 UTC (permalink / raw)
  To: Thomas Huth, qemu-devel, Alistair Francis; +Cc: QEMU Trivial, Laurent Vivier

27.02.2017 22:36, Thomas Huth wrote:
> On 25.01.2017 21:45, Thomas Huth wrote:
>> When running QEMU with "-M none -device loader,file=kernel.elf", it
>> currently crashes with a segmentation fault, because the "none"-machine
>> does not have any CPU by default and the generic loader code tries
>> to dereference s->cpu. Fix it by adding an appropriate check for a
>> NULL pointer.

Applied to -trivial, thanks!

/mjt


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

end of thread, other threads:[~2017-04-23 17:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1485377117-18105-1-git-send-email-thuth@redhat.com>
2017-02-27 19:36 ` [Qemu-trivial] [Qemu-devel] [PATCH] hw/core/generic-loader: Fix crash when running without CPU Thomas Huth
2017-04-23 17:34   ` [Qemu-trivial] " Michael Tokarev

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