Skip to contentSkip to conversation

Don't crash on keyboard input with no handler

PATCH Superseded Don Koch 2 participants 3 messages Nov 19, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Don Koch

author
#0 lore raw

PATCH 1/1 Don't crash on keyboard input with no handler

Prevent a call to put_kbd if null.

On shutdown of some OSes, the keyboard handler goes away before the system is down. If a key is typed during this window, qemu crashes.

---
I left the printf call, originally for testing, but useful as a sanity check if the user wonders why his keyboard input was ignored. AFAIC, it can be removed.

PS: Anthony, your address in the MAINTAINER file is still at ibm. I assume that is no longer correct, yes?

 ui/input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ui/input.c +4 -1
index 92c44ca..28ef6a6 100644
@@ -415,8 +415,10 @@ void kbd_put_keycode(int keycode)
         return;
     }
     if (entry) {
-        entry->put_kbd(entry->opaque, keycode);
+        if (entry->put_kbd)
+            entry->put_kbd(entry->opaque, keycode);
+        else
+            printf("%s: no keyboard handler\n", __FUNCTION__);
     }
 }
 
Signature · 1 line
1.8.1.4
#1 lore raw

Am 19.11.2013 19:26, schrieb Don Koch:

Quoted 10 lines

Prevent a call to put_kbd if null.

On shutdown of some OSes, the keyboard handler goes away before the system is down. If a key is typed during this window, qemu crashes.

---
I left the printf call, originally for testing, but useful as a sanity check if the user wonders why his keyboard input was ignored. AFAIC, it can be removed.

I'd remove that printf and combine the two if statements in the final patch.

Quoted 3 lines

PS: Anthony, your address in the MAINTAINER file is still at ibm. I assume that is no longer correct, yes?

The address is correct in the latest git version.

Quoted 10 lines
 ui/input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ui/input.c +0 -0
index 92c44ca..28ef6a6 100644
@@ -415,8 +415,10 @@ void kbd_put_keycode(int keycode)
         return;

ui/input.c void kbd_put_keycode(int keycode) · line 424

Quoted 10 lines
ui/input.c +4 -1
     }
     if (entry) {
-        entry->put_kbd(entry->opaque, keycode);
+        if (entry->put_kbd)
+            entry->put_kbd(entry->opaque, keycode);
+        else
+            printf("%s: no keyboard handler\n", __FUNCTION__);
     }
 }
 

Please check the coding style with scripts/checkpatch.pl.

Regards,
Stefan Weil

author
#2 lore raw
Quoted 6 lines · Stefan Weil

Am 19.11.2013 19:26, schrieb Don Koch:

Quoted 5 lines

Prevent a call to put_kbd if null.

On shutdown of some OSes, the keyboard handler goes away before the system is down. If a key is typed during this window, qemu crashes.

Quoted 7 lines
Quoted 5 lines

---
I left the printf call, originally for testing, but useful as a sanity check if the user wonders why his keyboard input was ignored. AFAIC, it can be removed.

I'd remove that printf and combine the two if statements in the final patch.

Works for me (if nobody thinks otherwise).

Quoted 5 lines
Quoted 3 lines

PS: Anthony, your address in the MAINTAINER file is still at ibm. I assume that is no longer correct, yes?

The address is correct in the latest git version.

Count on me to be in the wrong branch when I checked that.

Quoted 15 lines
Quoted 15 lines
 ui/input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ui/input.c +2 -1
index 92c44ca..28ef6a6 100644
@@ -415,8 +415,10 @@ void kbd_put_keycode(int keycode)
         return;
     }
     if (entry) {
-        entry->put_kbd(entry->opaque, keycode);
+        if (entry->put_kbd)
+            entry->put_kbd(entry->opaque, keycode);
Quoted 8 lines

ui/input.c void kbd_put_keycode(int keycode) · line 424

Quoted 5 lines
ui/input.c +2 -0
+        else
+            printf("%s: no keyboard handler\n", __FUNCTION__);
     }
 }
 

Please check the coding style with scripts/checkpatch.pl.

Of course, I remembered to do this afterwards. Turns out, the only problems will go away if I drop the printf. I meant to send a follow-up stating that and that I would wait to see what the consensus was on the printf before applying the appropriate changes (thunderbird had other ideas :-( ).

Quoted 3 lines

Regards,
Stefan Weil

Thanks,
-d