From: Tuomas Tynkkynen Date: Tue, 18 Jun 2013 10:14:41 +0000 (+0300) Subject: regulator: tps62360: Fix crash in i2c_driver .probe X-Git-Tag: next-20130619~43^2^2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=0a62d03b4844988c5477f13bd17c3553f816ce87;p=karo-tx-linux.git 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 Reviewed-by: Stephen Warren Signed-off-by: Tuomas Tynkkynen Signed-off-by: Mark Brown --- 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, int chip_id; pdata = client->dev.platform_data; - chip_id = id->driver_data; if (client->dev.of_node) { const struct of_device_id *match; @@ -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) { @@ -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;