diff options
author | Wen Yang <[email protected]> | 2019-12-01 11:02:50 +0800 |
---|---|---|
committer | Mark Brown <[email protected]> | 2019-12-03 12:18:33 +0000 |
commit | a3cde9534ebdafe18a9bbab208df724c57e6c8e8 (patch) | |
tree | b92322507f578fa544c9430a6c02031e815e7a3f /lib/netdev-notifier-error-inject.c | |
parent | 4affd79a125ac91e6a53be843ea3960a8fc00cbb (diff) |
regulator: core: fix regulator_register() error paths to properly release rdev
There are several issues with the error handling code of
the regulator_register() function:
ret = device_register(&rdev->dev);
if (ret != 0) {
put_device(&rdev->dev); --> rdev released
goto unset_supplies;
}
...
unset_supplies:
...
unset_regulator_supplies(rdev); --> use-after-free
...
clean:
if (dangling_of_gpiod)
gpiod_put(config->ena_gpiod);
kfree(rdev); --> double free
We add a variable to record the failure of device_register() and
move put_device() down a bit to avoid the above issues.
Fixes: c438b9d01736 ("regulator: core: Move registration of regulator device")
Signed-off-by: Wen Yang <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Diffstat (limited to 'lib/netdev-notifier-error-inject.c')
0 files changed, 0 insertions, 0 deletions