Commit 1648237d authored by Dirk Eibach's avatar Dirk Eibach Committed by Grant Likely

gpio/pca953x: Fix wrong pointer type

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.

v3: - assume big-endian properties
    - check property size
v2: - removed bogus check for negative property values
Signed-off-by: default avatarDirk Eibach <eibach@gdsys.de>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent c4376670
...@@ -448,7 +448,8 @@ pca953x_get_alt_pdata(struct i2c_client *client) ...@@ -448,7 +448,8 @@ pca953x_get_alt_pdata(struct i2c_client *client)
{ {
struct pca953x_platform_data *pdata; struct pca953x_platform_data *pdata;
struct device_node *node; struct device_node *node;
const uint16_t *val; const __be32 *val;
int size;
node = client->dev.of_node; node = client->dev.of_node;
if (node == NULL) if (node == NULL)
...@@ -461,13 +462,13 @@ pca953x_get_alt_pdata(struct i2c_client *client) ...@@ -461,13 +462,13 @@ pca953x_get_alt_pdata(struct i2c_client *client)
} }
pdata->gpio_base = -1; 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) {
if (*val < 0) if (size != sizeof(*val))
dev_warn(&client->dev, dev_warn(&client->dev, "%s: wrong linux,gpio-base\n",
"invalid gpio-base in device tree\n"); node->full_name);
else else
pdata->gpio_base = *val; pdata->gpio_base = be32_to_cpup(val);
} }
val = of_get_property(node, "polarity", NULL); val = of_get_property(node, "polarity", NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment