From patchwork Fri Aug 3 01:01:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 1268431 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CC0EDDF223 for ; Fri, 3 Aug 2012 01:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752616Ab2HCBBg (ORCPT ); Thu, 2 Aug 2012 21:01:36 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:64010 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752328Ab2HCBBf (ORCPT ); Thu, 2 Aug 2012 21:01:35 -0400 Received: by ghrr11 with SMTP id r11so192478ghr.19 for ; Thu, 02 Aug 2012 18:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=awblsWlKEIgoDD/WCF1mvnj2ufBrJzIk1jMTiBbBwdw=; b=mMRmwvqYRIhcytjBWVXwOLO/2ZiQWZ0xJ7XOCN8cjta6Rt3K6+kudDYzbLbRds0asp ImBRgz+rfC8HkxrnamggFQpRvL2KAszdf7+Pc2TWvpXHj9ao4ww8oGaPdCXrtGodyGyG vYRchv+uFVkYY2LHwNmQBXpQKx1AjvsuZeYClU7WLXuxCs4E7PIDnV9glJyXC34LsKAR sDfEGlFSFE2+hIpbwKAPg3izHqc7Gz479ZjyNI/HA11KnX+pCB0hsR8VzGH70MHhKUkA c8piHZYxXovxSVvQqSVzqXUy6vcWpatxDqGU3gbAarvIdZ/rKxpwwcy/Ygzq2YLDBsBo Uk8w== MIME-Version: 1.0 Received: by 10.60.168.230 with SMTP id zz6mr41294060oeb.11.1343955694724; Thu, 02 Aug 2012 18:01:34 -0700 (PDT) Received: by 10.76.7.113 with HTTP; Thu, 2 Aug 2012 18:01:34 -0700 (PDT) In-Reply-To: References: Date: Thu, 2 Aug 2012 22:01:34 -0300 Message-ID: Subject: Re: imx51 crashes at gpio_keys_probe From: Fabio Estevam To: Shawn Guo , rob.herring@calxeda.com Cc: linux-input@vger.kernel.org, Dmitry Torokhov , aletes.xgr@gmail.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Thu, Aug 2, 2012 at 8:58 PM, Fabio Estevam wrote: > On Thu, Aug 2, 2012 at 7:49 PM, Fabio Estevam 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: Acked-by: Alexandre Pereira da Silva --- 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) {