Kevin Wolf a9d52a7563 block/qdev: Fix NULL access when using BB twice
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 <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-07-05 16:46:26 +02:00
..
2016-07-01 14:38:54 +02:00
2016-07-04 13:15:22 +01:00
2016-06-30 19:00:02 +01:00
2016-06-29 19:14:48 +01:00
2016-06-17 16:33:48 +10:00
2016-05-29 09:11:10 +02:00
2016-06-14 15:59:13 +01:00
2016-06-29 19:14:48 +01:00
2016-06-29 14:03:46 +02:00
2016-05-18 15:04:27 +03:00
2016-06-07 18:02:48 +03:00
2016-06-29 14:03:48 +02:00
2016-05-29 09:11:10 +02:00
2016-06-24 05:13:57 +03:00
2016-06-17 03:28:03 +03:00
2016-01-29 15:07:25 +00:00
2016-06-24 05:13:57 +03:00
2016-07-04 13:15:22 +01:00
2016-06-22 12:53:26 +02:00
2016-06-22 11:28:42 +01:00
2015-12-22 18:39:19 +02:00