From dfb85ba1140ab649f6f0bf3e502ac37c0f69dbcb Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 7 Apr 2015 23:06:46 +0100 Subject: regulator: max8660: fix assignment of pdata to data that becomes dead pdata is assigned to &pdata_of, however, pdata_of becomes dead (when it goes out of scope) so pdata effectively becomes a dead pointer to the out of scope object. This is detected by static analysis: [drivers/regulator/max8660.c:411]: (error) Dead pointer usage. Pointer 'pdata' is dead if it has been assigned '&pdata_of' at line 404. Move declaration of pdata_of so it is always in scope. Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- drivers/regulator/max8660.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/regulator/max8660.c') diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 7eee2ca18541..f187c8f13e22 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c @@ -382,7 +382,7 @@ static int max8660_probe(struct i2c_client *client, const struct i2c_device_id *i2c_id) { struct device *dev = &client->dev; - struct max8660_platform_data *pdata = dev_get_platdata(dev); + struct max8660_platform_data pdata_of, *pdata = dev_get_platdata(dev); struct regulator_config config = { }; struct max8660 *max8660; int boot_on, i, id, ret = -EINVAL; @@ -391,7 +391,6 @@ static int max8660_probe(struct i2c_client *client, if (dev->of_node && !pdata) { const struct of_device_id *id; - struct max8660_platform_data pdata_of; id = of_match_device(of_match_ptr(max8660_dt_ids), dev); if (!id) -- cgit v1.2.3 From c0cf5a59fb69527151eb8e332a1b9660200f66c6 Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Fri, 10 Apr 2015 15:23:42 +0200 Subject: regulator: max8660: Handle empty regulator data It is not necessary to have regulator init data for a regulator. This patch removes the necessity of this data and handles a NULL pointer properly. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- drivers/regulator/max8660.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/regulator/max8660.c') diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index f187c8f13e22..4071d74fa828 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c @@ -442,9 +442,9 @@ static int max8660_probe(struct i2c_client *client, for (i = 0; i < pdata->num_subdevs; i++) { if (!pdata->subdevs[i].platform_data) - return ret; - - boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; + boot_on = false; + else + boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; switch (pdata->subdevs[i].id) { case MAX8660_V3: -- cgit v1.2.3