qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
To: peter.maydell@linaro.org
Cc: kwolf@redhat.com,
	Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, armbru@redhat.com, borntraeger@de.ibm.com,
	stefanha@redhat.com, mreitz@redhat.com
Subject: [Qemu-devel] [PATCH] scsi-hd: fix property unset case
Date: Wed,  4 Mar 2015 11:02:16 +0100	[thread overview]
Message-ID: <1425463336-20660-1-git-send-email-tumanova@linux.vnet.ibm.com> (raw)

commit "BlockConf: Call backend functions to detect geometry and
blocksizes" causes a segmentation fault on the invalid configuration of
a scsi device without a drive.

Lets check for conf.blk before calling blkconf_blocksizes. The error
will be handled later on in scsi_realize anyway.

Reported-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
---
 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 2921728..54d71f4 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) {
-- 
2.1.4

             reply	other threads:[~2015-03-04 10:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04 10:02 Ekaterina Tumanova [this message]
2015-03-04 12:23 ` [Qemu-devel] [PATCH] scsi-hd: fix property unset case Kevin Wolf
2015-03-04 13:58   ` Max Reitz
2015-03-04 14:12     ` Kevin Wolf
2015-03-04 14:13       ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425463336-20660-1-git-send-email-tumanova@linux.vnet.ibm.com \
    --to=tumanova@linux.vnet.ibm.com \
    --cc=armbru@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).