public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] keyboard: (samsung) fix a missing check of return value
@ 2018-12-26  1:51 Kangjie Lu
  2018-12-26 19:57 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-26  1:51 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, Dmitry Torokhov, Kees Cook, linux-input, linux-kernel

of_device_is_compatible() returns false if the device is incompatible.
The fix adds a check for its return value;

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/input/keyboard/samsung-keypad.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c
index 1fe1aa2adf85..5ba940f3f76e 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -387,9 +387,13 @@ static int samsung_keypad_probe(struct platform_device *pdev)
 	keypad->stopped = true;
 	init_waitqueue_head(&keypad->wait);
 
-	if (pdev->dev.of_node)
-		keypad->type = of_device_is_compatible(pdev->dev.of_node,
-					"samsung,s5pv210-keypad");
+	if (pdev->dev.of_node) {
+		error = of_device_is_compatible(pdev->dev.of_node,
+				"samsung,s5pv210-keypad");
+		if (!error)
+			return -EINVAL;
+		keypad->type = error;
+	}
 	else
 		keypad->type = platform_get_device_id(pdev)->driver_data;
 
-- 
2.17.2 (Apple Git-113)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-26 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-26  1:51 [PATCH] keyboard: (samsung) fix a missing check of return value Kangjie Lu
2018-12-26 19:57 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox