Skip to content

Commit

Permalink
regulator: tps62360: Fix crash in i2c_driver .probe
Browse files Browse the repository at this point in the history
Commit "i2c: core: make it possible to match a pure device tree driver"
changed semantics of the i2c probing for device tree devices.
Device tree probed devices now get a NULL i2c_device_id pointer.
This caused kernel panics due to NULL dereference.

Tested-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Tuomas Tynkkynen authored and Mark Brown committed Jun 18, 2013
1 parent 7d13205 commit 0a62d03
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/regulator/tps62360-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ static int tps62360_probe(struct i2c_client *client,
int chip_id;

pdata = client->dev.platform_data;
chip_id = id->driver_data;

if (client->dev.of_node) {
const struct of_device_id *match;
Expand All @@ -364,6 +363,11 @@ static int tps62360_probe(struct i2c_client *client,
chip_id = (int)match->data;
if (!pdata)
pdata = of_get_tps62360_platform_data(&client->dev);
} else if (id) {
chip_id = id->driver_data;
} else {
dev_err(&client->dev, "No device tree match or id table match found\n");
return -ENODEV;
}

if (!pdata) {
Expand Down Expand Up @@ -402,7 +406,7 @@ static int tps62360_probe(struct i2c_client *client,
return -ENODEV;
}

tps->desc.name = id->name;
tps->desc.name = client->name;
tps->desc.id = 0;
tps->desc.ops = &tps62360_dcdc_ops;
tps->desc.type = REGULATOR_VOLTAGE;
Expand Down

0 comments on commit 0a62d03

Please sign in to comment.