From: Anthony Liguori <aliguori@us.ibm.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] vl.c: Avoid segfault when started with no arguments
Date: Fri, 24 Feb 2012 13:49:14 -0600 [thread overview]
Message-ID: <4F47E9BA.1020903@us.ibm.com> (raw)
In-Reply-To: <1329950400-24354-1-git-send-email-peter.maydell@linaro.org>
On 02/22/2012 04:40 PM, Peter Maydell wrote:
> Fix a bug (introduced in commit a0abe47) where a command line which
> specified no machine arguments (either explicitly or implicitly via
> -kernel&co) would result in a segfault because of a NULL pointer
> returned from qemu_opts_find(qemu_find_opts("machine"), 0).
>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
Applied. Thanks.
Regards,
Anthony Liguori
> ---
> Oops, sorry about that... I must have tested the case where you do
> pass -kernel&co but forgot to test the case where you don't.
>
> vl.c | 17 ++++++++++-------
> 1 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index 7a8cc08..8375576 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2188,7 +2188,7 @@ int main(int argc, char **argv, char **envp)
> DisplayState *ds;
> DisplayChangeListener *dcl;
> int cyls, heads, secs, translation;
> - QemuOpts *hda_opts = NULL, *opts;
> + QemuOpts *hda_opts = NULL, *opts, *machine_opts;
> QemuOptsList *olist;
> int optind;
> const char *optarg;
> @@ -3247,12 +3247,15 @@ int main(int argc, char **argv, char **envp)
> exit(1);
> }
>
> - kernel_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> - 0), "kernel");
> - initrd_filename = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> - 0), "initrd");
> - kernel_cmdline = qemu_opt_get(qemu_opts_find(qemu_find_opts("machine"),
> - 0), "append");
> + machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
> + if (machine_opts) {
> + kernel_filename = qemu_opt_get(machine_opts, "kernel");
> + initrd_filename = qemu_opt_get(machine_opts, "initrd");
> + kernel_cmdline = qemu_opt_get(machine_opts, "append");
> + } else {
> + kernel_filename = initrd_filename = kernel_cmdline = NULL;
> + }
> +
> if (!kernel_cmdline) {
> kernel_cmdline = "";
> }
prev parent reply other threads:[~2012-02-24 19:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-22 22:40 [Qemu-devel] [PATCH] vl.c: Avoid segfault when started with no arguments Peter Maydell
2012-02-24 19:49 ` Anthony Liguori [this message]
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=4F47E9BA.1020903@us.ibm.com \
--to=aliguori@us.ibm.com \
--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).