summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTuomas Tynkkynen <ttynkkynen@nvidia.com>2013-06-18 06:14:41 -0400
committerMark Brown <broonie@linaro.org>2013-06-18 07:45:09 -0400
commit0a62d03b4844988c5477f13bd17c3553f816ce87 (patch)
tree2179be4814fedc7633f2d0db130d4f00d230e87f
parent7d132055814ef17a6c7b69f342244c410a5e000f (diff)
regulator: tps62360: Fix crash in i2c_driver .probe
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>
-rw-r--r--drivers/regulator/tps62360-regulator.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c
index 612919c3081c..a490d5b749b2 100644
--- a/drivers/regulator/tps62360-regulator.c
+++ b/drivers/regulator/tps62360-regulator.c
@@ -351,7 +351,6 @@ static int tps62360_probe(struct i2c_client *client,
351 int chip_id; 351 int chip_id;
352 352
353 pdata = client->dev.platform_data; 353 pdata = client->dev.platform_data;
354 chip_id = id->driver_data;
355 354
356 if (client->dev.of_node) { 355 if (client->dev.of_node) {
357 const struct of_device_id *match; 356 const struct of_device_id *match;
@@ -364,6 +363,11 @@ static int tps62360_probe(struct i2c_client *client,
364 chip_id = (int)match->data; 363 chip_id = (int)match->data;
365 if (!pdata) 364 if (!pdata)
366 pdata = of_get_tps62360_platform_data(&client->dev); 365 pdata = of_get_tps62360_platform_data(&client->dev);
366 } else if (id) {
367 chip_id = id->driver_data;
368 } else {
369 dev_err(&client->dev, "No device tree match or id table match found\n");
370 return -ENODEV;
367 } 371 }
368 372
369 if (!pdata) { 373 if (!pdata) {
@@ -402,7 +406,7 @@ static int tps62360_probe(struct i2c_client *client,
402 return -ENODEV; 406 return -ENODEV;
403 } 407 }
404 408
405 tps->desc.name = id->name; 409 tps->desc.name = client->name;
406 tps->desc.id = 0; 410 tps->desc.id = 0;
407 tps->desc.ops = &tps62360_dcdc_ops; 411 tps->desc.ops = &tps62360_dcdc_ops;
408 tps->desc.type = REGULATOR_VOLTAGE; 412 tps->desc.type = REGULATOR_VOLTAGE;