linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Mike Dunn <mikedunn@newsguy.com>
Cc: linux-input@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Chao Xie <chao.xie@marvell.com>,
	Robert Jarzmik <robert.jarzmik@free.fr>
Subject: Re: [PATCH] input: pxa27x_keypad: fix NULL pointer dereference
Date: Mon, 16 Sep 2013 18:49:53 +0200	[thread overview]
Message-ID: <201309161849.53556.marex@denx.de> (raw)
In-Reply-To: <1379349842-13089-1-git-send-email-mikedunn@newsguy.com>

Dear Mike Dunn,

> 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>
> ---
>  drivers/input/keyboard/pxa27x_keypad.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/keyboard/pxa27x_keypad.c
> b/drivers/input/keyboard/pxa27x_keypad.c index 134c3b4..3b2a614 100644
> --- a/drivers/input/keyboard/pxa27x_keypad.c
> +++ b/drivers/input/keyboard/pxa27x_keypad.c
> @@ -795,8 +795,10 @@ static int pxa27x_keypad_probe(struct platform_device
> *pdev) goto failed_put_clk;
>  	}
> 
> -	if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) ||
> -	    (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {
> +	if ((keypad->pdata->enable_rotary0 &&
> +	     keypad->rotary_rel_code[0] != -1) ||
> +	    (keypad->pdata->enable_rotary1 &&
> +	     keypad->rotary_rel_code[1] != -1)) {
>  		input_dev->evbit[0] |= BIT_MASK(EV_REL);
>  	}

Nice find. Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

  reply	other threads:[~2013-09-16 16:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16 16:44 [PATCH] input: pxa27x_keypad: fix NULL pointer dereference Mike Dunn
2013-09-16 16:49 ` Marek Vasut [this message]
2013-09-16 17:06   ` Dmitry Torokhov
2013-09-18  4:05     ` Mike Dunn
2013-09-18  4:24       ` Dmitry Torokhov
2013-09-18 14:28         ` Mike Dunn

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=201309161849.53556.marex@denx.de \
    --to=marex@denx.de \
    --cc=chao.xie@marvell.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --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).