Received: from [140.186.70.92] (port=38037 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PnsGg-0002nJ-39 for qemu-devel@nongnu.org; Fri, 11 Feb 2011 07:38:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PnsGe-00068i-Vd for qemu-devel@nongnu.org; Fri, 11 Feb 2011 07:38:33 -0500 Received: from smtp.ctxuk.citrix.com ([62.200.22.115]:23027 helo=SMTP.EU.CITRIX.COM) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PnsGe-00068G-Oj for qemu-devel@nongnu.org; Fri, 11 Feb 2011 07:38:32 -0500 Date: Fri, 11 Feb 2011 12:38:29 +0000 From: Stefano Stabellini Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Subject: [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org When disk is a cdrom and the drive is empty the "params" node in xenstore might be missing completely: cope with it instead of segfaulting. Signed-off-by: Stefano Stabellini diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 134ac33..e553c4c 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -577,12 +577,13 @@ static int blk_init(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); int index, qflags, have_barriers, info = 0; - char *h; + char *h = NULL; /* read xenstore entries */ if (blkdev->params == NULL) { blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params"); - h = strchr(blkdev->params, ':'); + if (blkdev->params != NULL) + h = strchr(blkdev->params, ':'); if (h != NULL) { blkdev->fileproto = blkdev->params; blkdev->filename = h+1;