From df1d4c341a735334de23513f17bf110c8c49b3e7 Mon Sep 17 00:00:00 2001 From: Ekaterina Tumanova Date: Wed, 4 Mar 2015 11:02:16 +0100 Subject: [PATCH] scsi-hd: fix property unset case Commit c53659f0 ("BlockConf: Call backend functions to detect geometry and blocksizes") causes a segmentation fault on the invalid configuration of a scsi device without a drive. Let's check for conf.blk before calling blkconf_blocksizes. The error will be handled later on in scsi_realize anyway. Reported-by: Max Reitz Reviewed-by: Stefan Hajnoczi Reviewed-by: Max Reitz Signed-off-by: Ekaterina Tumanova Signed-off-by: Kevin Wolf --- hw/scsi/scsi-disk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 2921728be4..54d71f4c03 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2291,7 +2291,12 @@ static void scsi_realize(SCSIDevice *dev, Error **errp) static void scsi_hd_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); - blkconf_blocksizes(&s->qdev.conf); + /* can happen for devices without drive. The error message for missing + * backend will be issued in scsi_realize + */ + if (s->qdev.conf.blk) { + blkconf_blocksizes(&s->qdev.conf); + } s->qdev.blocksize = s->qdev.conf.logical_block_size; s->qdev.type = TYPE_DISK; if (!s->product) {