adb_device_realizefn() returns early when the bus is full but does
not set errp, so the caller has no way to know the device failed to
realize. Set an error so the failure is properly propagated.

Reported-by: Pavee Hui <[email protected]>
Fixes: 0606b2883038 ("adb: introduce realize/unrealize and VMStateDescription 
for ADB bus")
Signed-off-by: Marc-André Lureau <[email protected]>
---
 hw/input/adb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/input/adb.c b/hw/input/adb.c
index b6319fa31535..54d00e2cd30c 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "hw/input/adb.h"
 #include "hw/core/qdev-properties.h"
+#include "qapi/error.h"
 #include "migration/vmstate.h"
 #include "qemu/module.h"
 #include "qemu/timer.h"
@@ -308,6 +309,7 @@ static void adb_device_realizefn(DeviceState *dev, Error 
**errp)
     ADBBusState *bus = ADB_BUS(qdev_get_parent_bus(dev));
 
     if (bus->nb_devices >= MAX_ADB_DEVICES) {
+        error_setg(errp, "Too many ADB devices");
         return;
     }
 

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to