All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Kangjie Lu <kjlu@umn.edu>
Cc: pakki001@umn.edu, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] input: pm8xxx-vibrator: fix a potential NULL pointer dereference
Date: Fri, 26 Apr 2019 17:27:08 -0700	[thread overview]
Message-ID: <20190427002708.GC42369@dtor-ws> (raw)
In-Reply-To: <20190309053922.22212-1-kjlu@umn.edu>

Hi Kangjie,

On Fri, Mar 08, 2019 at 11:39:21PM -0600, Kangjie Lu wrote:
> In case of_device_get_match_data fails to find the matched data,
> returns -ENODEV

How can this happen? We will not match again the device if compatible is
not present in the table.

If this happens I'd rather we crash and burn instead of silently
ignoring the failure.

Thanks.

> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/input/misc/pm8xxx-vibrator.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
> index 7dd1c1fbe42a..740e59c11808 100644
> --- a/drivers/input/misc/pm8xxx-vibrator.c
> +++ b/drivers/input/misc/pm8xxx-vibrator.c
> @@ -196,6 +196,8 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
>  	vib->vib_input_dev = input_dev;
>  
>  	regs = of_device_get_match_data(&pdev->dev);
> +	if (unlikely(!regs))
> +		return -ENODEV;
>  
>  	/* operate in manual mode */
>  	error = regmap_read(vib->regmap, regs->drv_addr, &val);
> -- 
> 2.17.1
> 

-- 
Dmitry

  reply	other threads:[~2019-04-27  0:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09  5:39 [PATCH] input: pm8xxx-vibrator: fix a potential NULL pointer dereference Kangjie Lu
2019-04-27  0:27 ` Dmitry Torokhov [this message]
2019-03-23  2:44 Kangjie Lu

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=20190427002708.GC42369@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.