regulator: core: correct double remove in rdev_deinit_debugfs
The current ordering of statements in the rdev_deinit_debugfs()
function causes freed memory to be dereferenced. This occurs
because the regulator_put(rdev->debug_consumer) call results in
debugfs_remove_recursive() being called on
rdev->debug_consumer->debugfs after it was previously removed
by the debugfs_remove_recursive() call to the parent dentry
rdev->debugfs.
Correct this by setting rdev->debug_consumer->debugfs to NULL
after calling debugfs_remove_recursive() for the parent directory
rdev->debugfs. This ensures that the regulator_put() call does
not try to remove the already removed subdirectory and also that
the debugfs callbacks which make use of rdev->debug_consumer are
removed before rdev->debug_consumer is freed in the regulator_put()
call.
Change-Id: Icb7da7949e401f64cf9e71c732cb40e43ddbdc01
Signed-off-by:
David Collins <collinsd@codeaurora.org>
Loading
Please register or sign in to comment