linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, Kees Cook <keescook@chromium.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] keyboard: (samsung) fix a missing check of return value
Date: Wed, 26 Dec 2018 11:57:20 -0800	[thread overview]
Message-ID: <20181226195720.GA5999@dtor-ws> (raw)
In-Reply-To: <20181226015131.71198-1-kjlu@umn.edu>

Hi,

On Tue, Dec 25, 2018 at 07:51:29PM -0600, Kangjie Lu wrote:
> 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;

What makes you think that not matching on this compatible is an error?
Have you looked at the rest of the dirver?

> +		keypad->type = error;
> +	}
>  	else
>  		keypad->type = platform_get_device_id(pdev)->driver_data;
>  
> -- 
> 2.17.2 (Apple Git-113)
> 

-- 
Dmitry

      reply	other threads:[~2018-12-26 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181226195720.GA5999@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kjlu@umn.edu \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pakki001@umn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).