linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Mike Dunn <mikedunn@newsguy.com>
Cc: linux-input@vger.kernel.org, Chao Xie <chao.xie@marvell.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Marek Vasut <marex@denx.de>
Subject: Re: [PATCH v2] input: pxa27x_keypad: fix NULL pointer dereference
Date: Wed, 18 Sep 2013 08:17:53 -0700	[thread overview]
Message-ID: <20130918151752.GA6325@core.coreip.homeip.net> (raw)
In-Reply-To: <1379516624-3789-1-git-send-email-mikedunn@newsguy.com>

On Wed, Sep 18, 2013 at 08:03:44AM -0700, Mike Dunn wrote:
> A NULL pointer dereference exception occurs in the driver probe function when
> device tree is used.  The pdata pointer will be NULL in this case, but the code
> dereferences it in all cases.  When device tree is used, a platform data
> structure is allocated and initialized, and in all cases this pointer is copied
> to the driver's private data, so the variable being tested should be accessed
> through the driver's private data structure.
> 
> Signed-off-by: Mike Dunn <mikedunn@newsguy.com>

Applied, thank you.

> ---
> Changelog:
> v2:
> Initialize pdata for DT case, instead of referencing through keypad struct.
> 
>  drivers/input/keyboard/pxa27x_keypad.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
> index 134c3b4..d02bdb2 100644
> --- a/drivers/input/keyboard/pxa27x_keypad.c
> +++ b/drivers/input/keyboard/pxa27x_keypad.c
> @@ -788,8 +788,10 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
>  
>  	if (pdata)
>  		error = pxa27x_keypad_build_keycode(keypad);
> -	else
> +	else {
>  		error = pxa27x_keypad_build_keycode_from_dt(keypad);
> +		pdata = keypad->pdata;
> +	}
>  	if (error) {
>  		dev_err(&pdev->dev, "failed to build keycode\n");
>  		goto failed_put_clk;
> -- 
> 1.8.1.5
> 

-- 
Dmitry

      reply	other threads:[~2013-09-18 15:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-18 15:03 [PATCH v2] input: pxa27x_keypad: fix NULL pointer dereference Mike Dunn
2013-09-18 15:17 ` 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=20130918151752.GA6325@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=chao.xie@marvell.com \
    --cc=linux-input@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=mikedunn@newsguy.com \
    --cc=robert.jarzmik@free.fr \
    /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).