The parameter "handler" is not checked, which may cause system
crash on some broken devices.

Signed-off-by: Zhenhua <[email protected]>
---
 drivers/tty/vt/keyboard.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index f4166263bb3a..f85c2d8c0b36 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1455,6 +1455,12 @@ static void kbd_event(struct input_handle *handle, 
unsigned int event_type,
                      unsigned int event_code, int value)
 {
        /* We are called with interrupts disabled, just take the lock */
+
+       if (handle == NULL || handle->dev == NULL) {
+               pr_err("device handler error.");
+               return;
+       }
+
        spin_lock(&kbd_event_lock);
 
        if (event_type == EV_MSC && event_code == MSC_RAW && 
HW_RAW(handle->dev))
-- 
2.14.1


Reply via email to