[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 25/43] block/qdev: Fix NULL access when using BB twic
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 25/43] block/qdev: Fix NULL access when using BB twice |
Date: |
Tue, 5 Jul 2016 17:50:34 +0200 |
BlockBackend has only a single pointer to its guest device, so it makes
sure that only a single guest device is attached to it. device-add
returns an error if you try to attach a second device to a BB. In order
to make the error message nicer, -device that manually connects to a
if=none block device get a different message than -drive that implicitly
creates a guest device. The if=... option is stored in DriveInfo.
However, since blockdev-add exists, not every BlockBackend has a
DriveInfo any more. Check that it exists before we dereference it.
QMP reproducer resulting in a segfault:
{"execute":"blockdev-add","arguments":{"options":{"id":"disk","driver":"file","filename":"/tmp/test.img"}}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"disk"}}
{"execute":"device_add","arguments":{"driver":"virtio-blk-pci","drive":"disk"}}
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
hw/core/qdev-properties-system.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 891219a..df38b8a 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -82,7 +82,7 @@ static void parse_drive(DeviceState *dev, const char *str,
void **ptr,
if (blk_attach_dev(blk, dev) < 0) {
DriveInfo *dinfo = blk_legacy_dinfo(blk);
- if (dinfo->type != IF_NONE) {
+ if (dinfo && dinfo->type != IF_NONE) {
error_setg(errp, "Drive '%s' is already in use because "
"it has been automatically connected to another "
"device (did you need 'if=none' in the drive options?)",
--
1.8.3.1
- [Qemu-block] [PULL 15/43] block: Set default request_alignment during bdrv_refresh_limits(), (continued)
- [Qemu-block] [PULL 15/43] block: Set default request_alignment during bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 18/43] block: Switch discard length bounds to byte-based, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 19/43] block: Drop raw_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 20/43] block: Split bdrv_merge_limits() from bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 21/43] block: Move request_alignment into BlockLimit, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 22/43] block: Fix error message style, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 24/43] block: fix return code for partial write for Linux AIO, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 23/43] block: Use bool as appropriate for BDS members, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 25/43] block/qdev: Fix NULL access when using BB twice,
Kevin Wolf <=
- [Qemu-block] [PULL 27/43] blkreplay: Convert to byte-based I/O, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 26/43] vvfat: Use BdrvChild for s->qcow, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 28/43] vhdx: Some more BlockBackend use in vhdx_create(), Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 29/43] block: Convert bdrv_co_readv() to BdrvChild, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 31/43] block: Convert bdrv_aio_readv() to BdrvChild, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 30/43] block: Convert bdrv_co_writev() to BdrvChild, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 32/43] block: Convert bdrv_aio_writev() to BdrvChild, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 33/43] block: Convert bdrv_co_do_readv/writev to BdrvChild, Kevin Wolf, 2016/07/05
- [Qemu-block] [PULL 34/43] block: Move bdrv_commit() to block/commit.c, Kevin Wolf, 2016/07/05