linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Pereira da Silva <aletes.xgr@gmail.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: Shawn Guo <shawn.guo@linaro.org>,
	rob.herring@calxeda.com, linux-input@vger.kernel.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: Re: imx51 crashes at gpio_keys_probe
Date: Thu, 2 Aug 2012 22:12:03 -0300	[thread overview]
Message-ID: <CAAAP30FEOAPOCC2aJMas_eRrHE43wgwRa_ddbETRgjVop1oQwQ@mail.gmail.com> (raw)
In-Reply-To: <CAOMZO5DV6yDh95SKAOtb1=tpbnNuztCsiCR+2QzX+KvrPq4FBg@mail.gmail.com>

On Thu, Aug 2, 2012 at 10:01 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Thu, Aug 2, 2012 at 8:58 PM, Fabio Estevam <festevam@gmail.com> wrote:
>> On Thu, Aug 2, 2012 at 7:49 PM, Fabio Estevam <festevam@gmail.com> wrote:
>>> Hi,
>>>
>>> Running today's linux-next on a imx51-babbage board I get the
>>> following (with a dt kernel):
>>>
>>> ...
>>> Unable to handle kernel NULL pointer dereference at virtual address 00000004
>>> pgd = 80004000
>>> [00000004] *pgd=00000000
>>> Internal error: Oops: 805 [#1] ARM
>>> Modules linked in:
>>
>> Reverting 30161f6b2e7d1 (Input: gpio_keys - clean up device tree
>> parser ) fixes the issue for me.
>
> Ok, the patch below fixes the issue on top of today's linux-next:

Hi,

Thanks for the fix.

Looks good to me.

You can add:
Acked-by: Alexandre Pereira da Silva <aletes.xgr@gmail.com>

> ---
>  drivers/input/keyboard/gpio_keys.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys.c
> b/drivers/input/keyboard/gpio_keys.c
> index 6ee68ec..620ef24 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -559,7 +559,6 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>         struct gpio_keys_button *button;
>         int error;
>         int nbuttons;
> -       int i;
>
>         node = dev->of_node;
>         if (!node) {
> @@ -580,9 +579,11 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>                 goto err_out;
>         }
>
> +       pdata->buttons = (struct gpio_keys_button *) (pdata + 1);
> +       pdata->nbuttons = nbuttons;
> +
>         pdata->rep = !!of_get_property(node, "autorepeat", NULL);
>
> -       i = 0;
>         for_each_child_of_node(node, pp) {
>                 enum of_gpio_flags flags;
>
> @@ -592,8 +593,13 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>                         continue;
>                 }
>
> -               button = &pdata->buttons[i++];
> -
> +               button = pdata->buttons;
> +
> +               if (!button)    {
> +                       error = -ENOMEM;
> +                       goto err_free_pdata;
> +               }
> +
>                 button->gpio = of_get_gpio_flags(pp, 0, &flags);
>                 button->active_low = flags & OF_GPIO_ACTIVE_LOW;
>
> @@ -614,6 +620,8 @@ gpio_keys_get_devtree_pdata(struct device *dev)
>                 if (of_property_read_u32(pp, "debounce-interval",
>                                          &button->debounce_interval))
>                         button->debounce_interval = 5;
> +
> +               button++;
>         }
>
>         if (pdata->nbuttons == 0) {
> --
> 1.7.1
>
> I based it on the initial dt submission from Shawn:
> http://patches.linaro.org/2743/
>
> Please let me know if the patch looks correct and I can send a formal
> one to the list.
>
> Thanks,
>
> Fabio Estevam

      reply	other threads:[~2012-08-03  1:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02 22:49 imx51 crashes at gpio_keys_probe Fabio Estevam
2012-08-02 23:58 ` Fabio Estevam
2012-08-03  1:01   ` Fabio Estevam
2012-08-03  1:12     ` Alexandre Pereira da Silva [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=CAAAP30FEOAPOCC2aJMas_eRrHE43wgwRa_ddbETRgjVop1oQwQ@mail.gmail.com \
    --to=aletes.xgr@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=festevam@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    --cc=shawn.guo@linaro.org \
    /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).