diff options
author | Paul Walmsley <paul@pwsan.com> | 2009-04-25 07:28:36 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2009-04-28 13:58:07 -0400 |
commit | 53032dafc6b93ac178ca2340ff8eb4ee2b3d1a92 (patch) | |
tree | a0bc0e11440df935a1a3b74f04cb91485fa2cd0a /drivers/regulator | |
parent | cd78dfc6c6e321a310a73ef7b0df3d262704dd55 (diff) |
regulator core: fix double-free in regulator_register() error path
During regulator registration, any error after device_register() will
cause a double-free on the struct regulator_dev 'rdev'. The bug is in
drivers/regulator/core.c:regulator_register():
...
scrub:
device_unregister(&rdev->dev);
clean:
kfree(rdev); <---
rdev = ERR_PTR(ret);
goto out;
...
device_unregister() calls regulator_dev_release() which frees rdev. The
subsequent kfree corrupts memory and causes some OMAP3 systems to oops on
boot in regulator_get().
Applies against 2.6.30-rc3.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/core.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index cb62be63caed..2f14c16f58c3 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -2080,6 +2080,10 @@ out: | |||
2080 | 2080 | ||
2081 | scrub: | 2081 | scrub: |
2082 | device_unregister(&rdev->dev); | 2082 | device_unregister(&rdev->dev); |
2083 | /* device core frees rdev */ | ||
2084 | rdev = ERR_PTR(ret); | ||
2085 | goto out; | ||
2086 | |||
2083 | clean: | 2087 | clean: |
2084 | kfree(rdev); | 2088 | kfree(rdev); |
2085 | rdev = ERR_PTR(ret); | 2089 | rdev = ERR_PTR(ret); |