[PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing

From: Lee Jones

Date: Fri Nov 27 2026 - 15:11:50 EST


When XenStore disables either the pointer or keyboard device,
xenkbd_probe() leaves info->ptr or info->kbd as NULL.
xenkbd_handle_key_event() dereferences info->ptr->keybit and
info->kbd->keybit before checking whether those pointers are valid,
causing a NULL pointer dereference in interrupt context on key events.

Check info->ptr and info->kbd before testing their keybit masks and
remove the unreachable NULL check below.

Fixes: 3ef8a2eeb6dc ("Input: xen-kbdfront - allow better run-time configuration")
Closes: https://sashiko.dev/#/bug/linux-9e0f9c2c-45ab-4045-80b4-47629154e917
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/input/misc/xen-kbdfront.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 6471d836f6fe..4e0bd4480f83 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -92,9 +92,9 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
struct input_dev *dev;
int value = key->pressed;

- if (test_bit(key->keycode, info->ptr->keybit)) {
+ if (info->ptr && test_bit(key->keycode, info->ptr->keybit)) {
dev = info->ptr;
- } else if (test_bit(key->keycode, info->kbd->keybit)) {
+ } else if (info->kbd && test_bit(key->keycode, info->kbd->keybit)) {
dev = info->kbd;
if (key->pressed && test_bit(key->keycode, info->kbd->key))
value = 2; /* Mark as autorepeat */
@@ -103,9 +103,6 @@ static void xenkbd_handle_key_event(struct xenkbd_info *info,
return;
}

- if (unlikely(!dev))
- return;
-
input_event(dev, EV_KEY, key->keycode, value);
input_sync(dev);
}
--
2.56.1.839.g22a8290db9-goog