On Wed, Jan 25, 2017 at 12:52 PM, Laurent Vivier <laur...@vivier.eu> wrote: > Le 25/01/2017 à 21:45, Thomas Huth a écrit : >> 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 <laur...@vivier.eu> >> Signed-off-by: Thomas Huth <th...@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; > > Should we just abort if s->cpu is NULL?
I agree, what is the use case where you are loading images without a CPU? If there is a use case (maybe some KVM thing?) then this patch looks fine to me. Thanks, Alistair > > Laurent > >