aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2017-03-17 20:32:42 +0800
committerMichael S. Tsirkin <mst@redhat.com>2017-03-22 17:54:32 +0200
commita77690c41da67d85bab1e784a9f24f18bc63dbd9 (patch)
tree5a69239afea638831aa8d7dd056e4658fa93ce8a /hw/virtio
parent55a19ad8b2d0797e3a8fe90ab99a9bb713824059 (diff)
downloadqemu-a77690c41da67d85bab1e784a9f24f18bc63dbd9.zip
qemu-a77690c41da67d85bab1e784a9f24f18bc63dbd9.tar.gz
qemu-a77690c41da67d85bab1e784a9f24f18bc63dbd9.tar.bz2
virtio: Fix error handling in virtio_bus_device_plugged
For one thing we shouldn't continue if an error happened, for the other two steps failing can cause an abort() in error_setg because we reuse the same errp blindly. Add error handling checks to fix both issues. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio-bus.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index a886011..3042232 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -25,6 +25,7 @@
#include "qemu/osdep.h"
#include "hw/hw.h"
#include "qemu/error-report.h"
+#include "qapi/error.h"
#include "hw/qdev.h"
#include "hw/virtio/virtio-bus.h"
#include "hw/virtio/virtio.h"
@@ -48,20 +49,33 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
bool has_iommu = virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+ Error *local_err = NULL;
DPRINTF("%s: plug device.\n", qbus->name);
if (klass->pre_plugged != NULL) {
- klass->pre_plugged(qbus->parent, errp);
+ klass->pre_plugged(qbus->parent, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
}
/* Get the features of the plugged device. */
assert(vdc->get_features != NULL);
vdev->host_features = vdc->get_features(vdev, vdev->host_features,
- errp);
+ &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
+ }
if (klass->device_plugged != NULL) {
- klass->device_plugged(qbus->parent, errp);
+ klass->device_plugged(qbus->parent, &local_err);
+ }
+ if (local_err) {
+ error_propagate(errp, local_err);
+ return;
}
if (klass->get_dma_as != NULL && has_iommu) {