Commit 5e172d75 authored by Laxman Dewangan's avatar Laxman Dewangan Committed by Lee Jones

mfd: palmas: Fix resource leak of i2c_dummy devices

Palmas device supports multiple i2c device address and the client
for these addressed are created in the driver as i2c_new_dummy().

The new devices are not getting released in error or removal path and
so it is causing resource leak.

Add the unregister of these newly created dummy devices to avoid resource
leaks.
Signed-off-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 7178347e
...@@ -422,7 +422,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ...@@ -422,7 +422,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
dev_err(palmas->dev, dev_err(palmas->dev,
"can't attach client %d\n", i); "can't attach client %d\n", i);
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err_i2c;
} }
palmas->i2c_clients[i]->dev.of_node = of_node_get(node); palmas->i2c_clients[i]->dev.of_node = of_node_get(node);
} }
...@@ -433,7 +433,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ...@@ -433,7 +433,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
dev_err(palmas->dev, dev_err(palmas->dev,
"Failed to allocate regmap %d, err: %d\n", "Failed to allocate regmap %d, err: %d\n",
i, ret); i, ret);
goto err; goto err_i2c;
} }
} }
...@@ -452,7 +452,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ...@@ -452,7 +452,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
reg); reg);
if (ret < 0) { if (ret < 0) {
dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret); dev_err(palmas->dev, "POLARITY_CTRL updat failed: %d\n", ret);
goto err; goto err_i2c;
} }
/* Change IRQ into clear on read mode for efficiency */ /* Change IRQ into clear on read mode for efficiency */
...@@ -466,7 +466,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ...@@ -466,7 +466,7 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip, IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip,
&palmas->irq_data); &palmas->irq_data);
if (ret < 0) if (ret < 0)
goto err; goto err_i2c;
no_irq: no_irq:
slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE); slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
...@@ -552,7 +552,6 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ...@@ -552,7 +552,6 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
} else if (pdata->pm_off && !pm_power_off) { } else if (pdata->pm_off && !pm_power_off) {
palmas_dev = palmas; palmas_dev = palmas;
pm_power_off = palmas_power_off; pm_power_off = palmas_power_off;
return ret;
} }
} }
...@@ -560,16 +559,26 @@ static int palmas_i2c_probe(struct i2c_client *i2c, ...@@ -560,16 +559,26 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
err_irq: err_irq:
regmap_del_irq_chip(palmas->irq, palmas->irq_data); regmap_del_irq_chip(palmas->irq, palmas->irq_data);
err: err_i2c:
for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
if (palmas->i2c_clients[i])
i2c_unregister_device(palmas->i2c_clients[i]);
}
return ret; return ret;
} }
static int palmas_i2c_remove(struct i2c_client *i2c) static int palmas_i2c_remove(struct i2c_client *i2c)
{ {
struct palmas *palmas = i2c_get_clientdata(i2c); struct palmas *palmas = i2c_get_clientdata(i2c);
int i;
regmap_del_irq_chip(palmas->irq, palmas->irq_data); regmap_del_irq_chip(palmas->irq, palmas->irq_data);
for (i = 1; i < PALMAS_NUM_CLIENTS; i++) {
if (palmas->i2c_clients[i])
i2c_unregister_device(palmas->i2c_clients[i]);
}
if (palmas == palmas_dev) { if (palmas == palmas_dev) {
pm_power_off = NULL; pm_power_off = NULL;
palmas_dev = NULL; palmas_dev = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment