提交 2663959a 编写于 作者: K Kangjie Lu 提交者: Greg Kroah-Hartman

leds: pca9532: fix a potential NULL pointer dereference

[ Upstream commit 0aab8e4df4702b31314a27ec4b0631dfad0fae0a ]

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: NKangjie Lu <kjlu@umn.edu>
Signed-off-by: NJacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: NSasha Levin (Microsoft) <sashal@kernel.org>
上级 13a6a6dd
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册