]> xenbits.xensource.com Git - qemu-xen-4.2-testing.git/commitdiff
qemu-xen: fix segfault with empty cdroms xen-4.1.0 xen-4.1.0-rc5 xen-4.1.0-rc6 xen-4.1.0-rc7 xen-4.1.0-rc8 xen-4.1.1 xen-4.1.1-rc1 xen-4.1.1-rc2 xen-4.1.2 xen-4.1.2-rc1 xen-4.1.2-rc2 xen-4.1.2-rc3
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 11 Feb 2011 17:54:51 +0000 (17:54 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 11 Feb 2011 17:54:51 +0000 (17:54 +0000)
When the cdrom is empty the params node in xenstore might be missing
completely.  Cope with it instead of segfaulting.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/xen_disk.c

index 218f65451a0bcca78a3b8aa0f1c50a806e74e294..6aebb77ba780631dac6e8c315f3fcefd57c4a5fb 100644 (file)
@@ -582,12 +582,13 @@ static int blk_init(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
     int mode, 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;