mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dirk Eibach <eibach@gdsys.de>
To: linux-kernel@vger.kernel.org
Cc: error27@gmail.com, grant.likely@secretlab.ca,
	Dirk Eibach <eibach@gdsys.de>
Subject: [PATCH v3] gpio: Fix wrong pointer type in pca953x
Date: Thu, 24 Feb 2011 10:20:43 +0100	[thread overview]
Message-ID: <1298539243-25150-1-git-send-email-eibach@gdsys.de> (raw)
In-Reply-To: <20110222123601.GA1966@bicker>

pca953x_get_alt_pdata() uses uint16_t* as result type for
of_get_property(), but numeric of values are __be32.

Checking for negative values is bogus because of-property
values are unsigned by definition.
Instead check for proper property size.

Signed-off-by: Dirk Eibach <eibach@gdsys.de>
---
Changes since v1:
- removed bogus check for negative property values

Changes since v2:
- assume big-endian properties
- check property size

 drivers/gpio/pca953x.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index a261972..694b0f9 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -448,7 +448,8 @@ pca953x_get_alt_pdata(struct i2c_client *client)
 {
 	struct pca953x_platform_data *pdata;
 	struct device_node *node;
-	const uint16_t *val;
+	const __be32 *val;
+	int size;
 
 	node = client->dev.of_node;
 	if (node == NULL)
@@ -461,13 +462,13 @@ pca953x_get_alt_pdata(struct i2c_client *client)
 	}
 
 	pdata->gpio_base = -1;
-	val = of_get_property(node, "linux,gpio-base", NULL);
+	val = of_get_property(node, "linux,gpio-base", &size);
 	if (val) {
-		if (*val < 0)
-			dev_warn(&client->dev,
-				 "invalid gpio-base in device tree\n");
+		if (size != sizeof(*val))
+			dev_warn(&client->dev, "%s: wrong linux,gpio-base\n",
+				 node->full_name);
 		else
-			pdata->gpio_base = *val;
+			pdata->gpio_base = be32_to_cpup(val);
 	}
 
 	val = of_get_property(node, "polarity", NULL);
-- 
1.5.6.5


  parent reply	other threads:[~2011-02-24  9:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22  8:56 [PATCH] " Dirk Eibach
2011-02-22 12:36 ` Dan Carpenter
2011-02-22 12:52   ` Eibach, Dirk
2011-02-22 13:28   ` [PATCH v2] " Dirk Eibach
2011-02-24  9:20   ` Dirk Eibach [this message]
2011-02-24 15:56     ` [PATCH v3] " Grant Likely

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=1298539243-25150-1-git-send-email-eibach@gdsys.de \
    --to=eibach@gdsys.de \
    --cc=error27@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.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

Powered by JetHome