Commit f322d5f0 authored by Wolfram Sang's avatar Wolfram Sang Committed by Samuel Ortiz

mfd: Fix dangling pointers

Fix I2C-drivers which missed setting clientdata to NULL before freeing the
structure it points to. Also fix drivers which do this _after_ the structure
was freed already.
Signed-off-by: default avatarWolfram Sang <w.sang@pengutronix.de>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent d84027bc
...@@ -202,6 +202,7 @@ static int __devexit pm860x_remove(struct i2c_client *client) ...@@ -202,6 +202,7 @@ static int __devexit pm860x_remove(struct i2c_client *client)
i2c_unregister_device(chip->companion); i2c_unregister_device(chip->companion);
i2c_set_clientdata(chip->companion, NULL); i2c_set_clientdata(chip->companion, NULL);
i2c_set_clientdata(chip->client, NULL); i2c_set_clientdata(chip->client, NULL);
i2c_set_clientdata(client, NULL);
kfree(chip); kfree(chip);
return 0; return 0;
} }
......
...@@ -920,6 +920,7 @@ static int __init ab3100_probe(struct i2c_client *client, ...@@ -920,6 +920,7 @@ static int __init ab3100_probe(struct i2c_client *client,
i2c_unregister_device(ab3100->testreg_client); i2c_unregister_device(ab3100->testreg_client);
exit_no_testreg_client: exit_no_testreg_client:
exit_no_detect: exit_no_detect:
i2c_set_clientdata(client, NULL);
kfree(ab3100); kfree(ab3100);
return err; return err;
} }
...@@ -941,6 +942,7 @@ static int __exit ab3100_remove(struct i2c_client *client) ...@@ -941,6 +942,7 @@ static int __exit ab3100_remove(struct i2c_client *client)
* their notifiers so deactivate IRQ * their notifiers so deactivate IRQ
*/ */
free_irq(client->irq, ab3100); free_irq(client->irq, ab3100);
i2c_set_clientdata(client, NULL);
kfree(ab3100); kfree(ab3100);
return 0; return 0;
} }
......
...@@ -544,6 +544,7 @@ static int __devexit da903x_remove(struct i2c_client *client) ...@@ -544,6 +544,7 @@ static int __devexit da903x_remove(struct i2c_client *client)
struct da903x_chip *chip = i2c_get_clientdata(client); struct da903x_chip *chip = i2c_get_clientdata(client);
da903x_remove_subdevs(chip); da903x_remove_subdevs(chip);
i2c_set_clientdata(client, NULL);
kfree(chip); kfree(chip);
return 0; return 0;
} }
......
...@@ -1228,6 +1228,7 @@ static int menelaus_probe(struct i2c_client *client, ...@@ -1228,6 +1228,7 @@ static int menelaus_probe(struct i2c_client *client,
free_irq(client->irq, menelaus); free_irq(client->irq, menelaus);
flush_scheduled_work(); flush_scheduled_work();
fail1: fail1:
i2c_set_clientdata(client, NULL);
kfree(menelaus); kfree(menelaus);
return err; return err;
} }
...@@ -1237,8 +1238,8 @@ static int __exit menelaus_remove(struct i2c_client *client) ...@@ -1237,8 +1238,8 @@ static int __exit menelaus_remove(struct i2c_client *client)
struct menelaus_chip *menelaus = i2c_get_clientdata(client); struct menelaus_chip *menelaus = i2c_get_clientdata(client);
free_irq(client->irq, menelaus); free_irq(client->irq, menelaus);
kfree(menelaus);
i2c_set_clientdata(client, NULL); i2c_set_clientdata(client, NULL);
kfree(menelaus);
the_menelaus = NULL; the_menelaus = NULL;
return 0; return 0;
} }
......
...@@ -679,6 +679,7 @@ static int __devexit pcf50633_remove(struct i2c_client *client) ...@@ -679,6 +679,7 @@ static int __devexit pcf50633_remove(struct i2c_client *client)
for (i = 0; i < PCF50633_NUM_REGULATORS; i++) for (i = 0; i < PCF50633_NUM_REGULATORS; i++)
platform_device_unregister(pcf->regulator_pdev[i]); platform_device_unregister(pcf->regulator_pdev[i]);
i2c_set_clientdata(client, NULL);
kfree(pcf); kfree(pcf);
return 0; return 0;
......
...@@ -530,8 +530,8 @@ static int __exit tps65010_remove(struct i2c_client *client) ...@@ -530,8 +530,8 @@ static int __exit tps65010_remove(struct i2c_client *client)
cancel_delayed_work(&tps->work); cancel_delayed_work(&tps->work);
flush_scheduled_work(); flush_scheduled_work();
debugfs_remove(tps->file); debugfs_remove(tps->file);
kfree(tps);
i2c_set_clientdata(client, NULL); i2c_set_clientdata(client, NULL);
kfree(tps);
the_tps = NULL; the_tps = NULL;
return 0; return 0;
} }
......
...@@ -82,6 +82,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c, ...@@ -82,6 +82,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
err: err:
i2c_set_clientdata(i2c, NULL);
kfree(wm8350); kfree(wm8350);
return ret; return ret;
} }
...@@ -91,6 +92,7 @@ static int wm8350_i2c_remove(struct i2c_client *i2c) ...@@ -91,6 +92,7 @@ static int wm8350_i2c_remove(struct i2c_client *i2c)
struct wm8350 *wm8350 = i2c_get_clientdata(i2c); struct wm8350 *wm8350 = i2c_get_clientdata(i2c);
wm8350_device_exit(wm8350); wm8350_device_exit(wm8350);
i2c_set_clientdata(i2c, NULL);
kfree(wm8350); kfree(wm8350);
return 0; return 0;
......
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