Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1727500

[PATCH 1/1] drivers/tty: check for null pointer

From Zhenhua <lizhenhuajiyang@163.com>
Newsgroups linux.kernel
Subject [PATCH 1/1] drivers/tty: check for null pointer
Date 2017-09-06 16:00 +0200
Message-ID <umISl-2uc-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Signed-off-by: Zhenhua <lizhenhuajiyang@163.com>
---
 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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 1/1] drivers/tty: check for null pointer Zhenhua <lizhenhuajiyang@163.com> - 2017-09-06 16:00 +0200

csiph-web