keyboard: (samsung) fix a missing check of return value
Subsystems (2)
PATCH 1/1 keyboard: (samsung) fix a missing check of return value
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 <[email protected]>
--- drivers/input/keyboard/samsung-keypad.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/input/keyboard/samsung-keypad.c +7 -3
@@ -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;
Signature · 1 line
2.17.2 (Apple Git-113)
Dmitry Torokhov
maintainerHi,
Quoted 14 lines · Kangjie Lu
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 <[email protected]>--- drivers/input/keyboard/samsung-keypad.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/input/keyboard/samsung-keypad.c +0
-0@@ -387,9 +387,13 @@ static int samsung_keypad_probe(struct platform_device *pdev) keypad->stopped = true;
drivers/input/keyboard/samsung-keypad.c static int samsung_keypad_probe(struct platform_device *pdev) · line 394
Quoted 10 lines
drivers/input/keyboard/samsung-keypad.c +5
-3init_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 ;
What makes you think that not matching on this compatible is an error? Have you looked at the rest of the dirver?
Quoted 8 lines
drivers/input/keyboard/samsung-keypad.c +2
-0+ keypad->type = error; + }else keypad->type =platform_get_device_id (pdev)->driver_data;Signature · 1 line
2.17.2 (Apple Git-113)
Signature · 1 line
Dmitry