aboutsummaryrefslogtreecommitdiff
path: root/hw/nubus
diff options
context:
space:
mode:
authorZhao Liu <zhao1.liu@intel.com>2024-07-24 00:18:02 +0800
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-07-23 22:34:09 +0200
commit2f28f28e74d9e8861701e5597b314fa85965ecd4 (patch)
treeb194717e7951c27ed4a940a925dcdd6f48ff151f /hw/nubus
parent1aef44805df33f3f6e6302984660f4ea6b31fb3e (diff)
hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler
According to the comment in qapi/error.h, dereferencing @errp requires ERRP_GUARD(): * = Why, when and how to use ERRP_GUARD() = * * Without ERRP_GUARD(), use of the @errp parameter is restricted: * - It must not be dereferenced, because it may be null. ... * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. * * Using it when it's not needed is safe, but please avoid cluttering * the source with useless code. In nubus_virtio_mmio_realize(), @errp is dereferenced without ERRP_GUARD(). Although nubus_virtio_mmio_realize() - as a DeviceClass.realize() method - is never passed a null @errp argument, it should follow the rules on @errp usage. Add the ERRP_GUARD() there. Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Message-ID: <20240723161802.1377985-1-zhao1.liu@intel.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'hw/nubus')
-rw-r--r--hw/nubus/nubus-virtio-mmio.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/nubus/nubus-virtio-mmio.c b/hw/nubus/nubus-virtio-mmio.c
index 58a63c84d0..7a98731c45 100644
--- a/hw/nubus/nubus-virtio-mmio.c
+++ b/hw/nubus/nubus-virtio-mmio.c
@@ -7,6 +7,7 @@
*/
#include "qemu/osdep.h"
+#include "qapi/error.h"
#include "hw/nubus/nubus-virtio-mmio.h"
@@ -23,6 +24,7 @@ static void nubus_virtio_mmio_set_input_irq(void *opaque, int n, int level)
static void nubus_virtio_mmio_realize(DeviceState *dev, Error **errp)
{
+ ERRP_GUARD();
NubusVirtioMMIODeviceClass *nvmdc = NUBUS_VIRTIO_MMIO_GET_CLASS(dev);
NubusVirtioMMIO *s = NUBUS_VIRTIO_MMIO(dev);
NubusDevice *nd = NUBUS_DEVICE(dev);