[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] cpu: Fix crash with empty -cpu option
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH] cpu: Fix crash with empty -cpu option |
Date: |
Thu, 18 Apr 2019 10:23:29 -0300 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Thu, Apr 18, 2019 at 01:22:16PM +0200, Igor Mammedov wrote:
> On Thu, 18 Apr 2019 00:45:01 -0300
> Eduardo Habkost <address@hidden> wrote:
>
> > Fix the following crash:
> >
> > $ qemu-system-x86_64 -cpu ''
> > qemu-system-x86_64: qom/cpu.c:291: cpu_class_by_name: \
> > Assertion `cpu_model && cc->class_by_name' failed.
> >
> > Regression test script included.
> >
> > Fixes: commit 99193d8f2ef5 ("cpu: drop unnecessary NULL check and
> > cpu_common_class_by_name()")
> > Signed-off-by: Eduardo Habkost <address@hidden>
> > ---
> > exec.c | 4 ++++
> > tests/acceptance/empty_cpu_model.py | 19 +++++++++++++++++++
> > 2 files changed, 23 insertions(+)
> > create mode 100644 tests/acceptance/empty_cpu_model.py
> >
> > diff --git a/exec.c b/exec.c
> > index 1ca95df9d8..d816b38863 100644
> > --- a/exec.c
> > +++ b/exec.c
> > @@ -999,6 +999,10 @@ const char *parse_cpu_option(MachineState *machine,
> > const char *cpu_option)
> > const char *cpu_type;
> >
> > model_pieces = g_strsplit(cpu_option, ",", 2);
> > + if (!model_pieces[0]) {
> > + error_report("-cpu option cannot be empty");
> > + exit(1);
>
> s/1/EXIT_FAILURE/
Why?
There are 753 instances of "exit(1)" in the tree, and 171
instances of "exit(EXIT_FAILURE)".
--
Eduardo