xen/blkback: don't call vbd_size() if bd_disk is NULL
authorLaszlo Ersek <lersek@redhat.com>
Wed, 25 May 2011 10:24:25 +0000 (12:24 +0200)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Wed, 1 Jun 2011 13:28:20 +0000 (09:28 -0400)
...because vbd_size() dereferences bd_disk if bd_part is NULL.

Signed-off-by: Laszlo Ersek<lersek@redhat.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkback/xenbus.c

index 34570823355be5715c35bc86eabfc33d7ea41b83..6cc0db1bf52252f2a981544116bf419d2a6a28e6 100644 (file)
@@ -357,14 +357,13 @@ static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle,
        }
 
        vbd->bdev = bdev;
-       vbd->size = vbd_sz(vbd);
-
        if (vbd->bdev->bd_disk == NULL) {
                DPRINTK("xen_vbd_create: device %08x doesn't exist.\n",
                        vbd->pdevice);
                xen_vbd_free(vbd);
                return -ENOENT;
        }
+       vbd->size = vbd_sz(vbd);
 
        if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
                vbd->type |= VDISK_CDROM;