From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSNHi-0001Z7-UO for qemu-devel@nongnu.org; Mon, 02 Mar 2015 05:09:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSNHh-0007ku-Lc for qemu-devel@nongnu.org; Mon, 02 Mar 2015 05:09:10 -0500 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:44111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSNHh-0007km-FY for qemu-devel@nongnu.org; Mon, 02 Mar 2015 05:09:09 -0500 Received: by wiwl15 with SMTP id l15so13483872wiw.3 for ; Mon, 02 Mar 2015 02:09:09 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 2 Mar 2015 11:08:44 +0100 Message-Id: <1425290934-60872-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1425290934-60872-1-git-send-email-pbonzini@redhat.com> References: <1425290934-60872-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 05/15] bootdevice: fix segment fault when booting guest with '-kernel' and '-initrd' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei From: Gonglei Reproducer: $./qemu-system-x86_64 --enable-kvm -kernel /home/vmlinuz-2.6.32.12-0.7-default \ -initrd /home/initrd-2.6.32.12-0.7-default -append \ "root=/dev/ram rw console=ttyS0,115200" -dtb guest.dtb -vnc :10 --monitor stdio -smp 2 QEMU 2.2.50 monitor - type 'help' for more information (qemu) Segmentation fault (core dumped) Reported-by: Edivaldo de Araujo Pereira Signed-off-by: Gonglei Message-Id: <1425001784-6752-1-git-send-email-arei.gonglei@huawei.com> Signed-off-by: Paolo Bonzini --- bootdevice.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index c3a010c..eacd8c8 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -221,10 +221,15 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes) } if (!ignore_suffixes) { - d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus, i->dev); - if (d) { - assert(!i->suffix); - suffix = d; + if (i->dev) { + d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus, + i->dev); + if (d) { + assert(!i->suffix); + suffix = d; + } else { + suffix = g_strdup(i->suffix); + } } else { suffix = g_strdup(i->suffix); } -- 2.3.0