Commit 0aab8e4d authored by Kangjie Lu's avatar Kangjie Lu Committed by Jacek Anaszewski

leds: pca9532: fix a potential NULL pointer dereference

In case of_match_device cannot find a match, return -EINVAL to avoid
NULL pointer dereference.

Fixes: fa4191a6 ("leds: pca9532: Add device tree support")
Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
parent 4cb65605
...@@ -513,6 +513,7 @@ static int pca9532_probe(struct i2c_client *client, ...@@ -513,6 +513,7 @@ static int pca9532_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
int devid; int devid;
const struct of_device_id *of_id;
struct pca9532_data *data = i2c_get_clientdata(client); struct pca9532_data *data = i2c_get_clientdata(client);
struct pca9532_platform_data *pca9532_pdata = struct pca9532_platform_data *pca9532_pdata =
dev_get_platdata(&client->dev); dev_get_platdata(&client->dev);
...@@ -528,8 +529,11 @@ static int pca9532_probe(struct i2c_client *client, ...@@ -528,8 +529,11 @@ static int pca9532_probe(struct i2c_client *client,
dev_err(&client->dev, "no platform data\n"); dev_err(&client->dev, "no platform data\n");
return -EINVAL; return -EINVAL;
} }
devid = (int)(uintptr_t)of_match_device( of_id = of_match_device(of_pca9532_leds_match,
of_pca9532_leds_match, &client->dev)->data; &client->dev);
if (unlikely(!of_id))
return -EINVAL;
devid = (int)(uintptr_t) of_id->data;
} else { } else {
devid = id->driver_data; devid = id->driver_data;
} }
......
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