From patchwork Fri Feb 11 12:38:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 82751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 53BBAB7131 for ; Fri, 11 Feb 2011 23:39:59 +1100 (EST) Received: from localhost ([127.0.0.1]:53179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PnsI0-0003IZ-3P for incoming@patchwork.ozlabs.org; Fri, 11 Feb 2011 07:39:56 -0500 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 X-IronPort-AV: E=Sophos;i="4.60,455,1291593600"; d="scan'208";a="4281919" Received: from lonpmailmx01.citrite.net ([10.30.224.162]) by LONPIPO01.EU.CITRIX.COM with ESMTP/TLS/RC4-MD5; 11 Feb 2011 12:38:29 +0000 Received: from kaball.uk.xensource.com (10.80.2.59) by smtprelay.citrix.com (10.30.224.162) with Microsoft SMTP Server id 8.2.255.0; Fri, 11 Feb 2011 12:38:29 +0000 Date: Fri, 11 Feb 2011 12:38:29 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball-desktop To: qemu-devel@nongnu.org Message-ID: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 62.200.22.115 Subject: [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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;