Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Tuomas Tynkkynen and committed by
Mark Brown
0a62d03b 7d132055

+6 -2
+6 -2
drivers/regulator/tps62360-regulator.c
··· 351 351 int chip_id; 352 352 353 353 pdata = client->dev.platform_data; 354 - chip_id = id->driver_data; 355 354 356 355 if (client->dev.of_node) { 357 356 const struct of_device_id *match; ··· 363 364 chip_id = (int)match->data; 364 365 if (!pdata) 365 366 pdata = of_get_tps62360_platform_data(&client->dev); 367 + } else if (id) { 368 + chip_id = id->driver_data; 369 + } else { 370 + dev_err(&client->dev, "No device tree match or id table match found\n"); 371 + return -ENODEV; 366 372 } 367 373 368 374 if (!pdata) { ··· 406 402 return -ENODEV; 407 403 } 408 404 409 - tps->desc.name = id->name; 405 + tps->desc.name = client->name; 410 406 tps->desc.id = 0; 411 407 tps->desc.ops = &tps62360_dcdc_ops; 412 408 tps->desc.type = REGULATOR_VOLTAGE;