From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S11Co-0000BS-Ej for qemu-devel@nongnu.org; Fri, 24 Feb 2012 14:53:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S11Cn-00064i-7J for qemu-devel@nongnu.org; Fri, 24 Feb 2012 14:53:26 -0500 Received: from e1.ny.us.ibm.com ([32.97.182.141]:60425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S11Cn-00064U-2k for qemu-devel@nongnu.org; Fri, 24 Feb 2012 14:53:25 -0500 Received: from /spool/local by e1.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 Feb 2012 14:53:20 -0500 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 67BE76E805F for ; Fri, 24 Feb 2012 14:49:38 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q1OJnKV83133654 for ; Fri, 24 Feb 2012 14:49:20 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q1OJnJqe025614 for ; Fri, 24 Feb 2012 17:49:20 -0200 Message-ID: <4F47E9BA.1020903@us.ibm.com> Date: Fri, 24 Feb 2012 13:49:14 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1329950400-24354-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1329950400-24354-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vl.c: Avoid segfault when started with no arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, patches@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 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 = ""; > }