mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
leds: pca9532: fix a potential NULL pointer dereference
[ Upstream commit0aab8e4df4] In case of_match_device cannot find a match, return -EINVAL to avoid NULL pointer dereference. Fixes:fa4191a609("leds: pca9532: Add device tree support") Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com> Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
13103fc1d5
commit
b491c6f370
@@ -488,6 +488,7 @@ static int pca9532_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
int devid;
|
||||
const struct of_device_id *of_id;
|
||||
struct pca9532_data *data = i2c_get_clientdata(client);
|
||||
struct pca9532_platform_data *pca9532_pdata =
|
||||
dev_get_platdata(&client->dev);
|
||||
@@ -503,8 +504,11 @@ static int pca9532_probe(struct i2c_client *client,
|
||||
dev_err(&client->dev, "no platform data\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
devid = (int)(uintptr_t)of_match_device(
|
||||
of_pca9532_leds_match, &client->dev)->data;
|
||||
of_id = of_match_device(of_pca9532_leds_match,
|
||||
&client->dev);
|
||||
if (unlikely(!of_id))
|
||||
return -EINVAL;
|
||||
devid = (int)(uintptr_t) of_id->data;
|
||||
} else {
|
||||
devid = id->driver_data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user