adb_kbd_realizefn calls parent_realize but does not check for
errors before continuing. When the caller passes errp as NULL,
a failure is silently ignored and qemu_input_handler_register
runs on a device that failed to realize.
Use ERRP_GUARD() and check *errp to properly detect and
propagate errors regardless of the caller's errp value.
Fixes: 77cb0f5aafc8 ("Split adb.c into adb.c, adb-mouse.c and adb-kbd.c")
Signed-off-by: Marc-André Lureau <[email protected]>
---
hw/input/adb-kbd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/input/adb-kbd.c b/hw/input/adb-kbd.c
index 8635354f024c..d4a131dc1295 100644
--- a/hw/input/adb-kbd.c
+++ b/hw/input/adb-kbd.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "hw/input/adb.h"
+#include "qapi/error.h"
#include "migration/vmstate.h"
#include "qemu/module.h"
#include "standard-headers/linux/input-event-codes.h"
@@ -385,7 +386,12 @@ static void adb_kbd_realizefn(DeviceState *dev, Error
**errp)
KBDState *s = ADB_KEYBOARD(dev);
ADBKeyboardClass *akc = ADB_KEYBOARD_GET_CLASS(dev);
+ ERRP_GUARD();
+
akc->parent_realize(dev, errp);
+ if (*errp) {
+ return;
+ }
s->hs = qemu_input_handler_register(dev, &adb_keyboard_handler);
}
--
2.56.0.rc0.29.g47ce80527c56