Skip to content

Commit ca46946

Browse files
alessandrocarminatibroonie
authored andcommitted
regulator: core: fix NULL dereference on unbind due to stale coupling data
Failing to reset coupling_desc.n_coupled after freeing coupled_rdevs can lead to NULL pointer dereference when regulators are accessed post-unbind. This can happen during runtime PM or other regulator operations that rely on coupling metadata. For example, on ridesx4, unbinding the 'reg-dummy' platform device triggers a panic in regulator_lock_recursive() due to stale coupling state. Ensure n_coupled is set to 0 to prevent access to invalid pointers. Signed-off-by: Alessandro Carminati <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d0b3b7b commit ca46946

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5639,6 +5639,7 @@ static void regulator_remove_coupling(struct regulator_dev *rdev)
56395639
ERR_PTR(err));
56405640
}
56415641

5642+
rdev->coupling_desc.n_coupled = 0;
56425643
kfree(rdev->coupling_desc.coupled_rdevs);
56435644
rdev->coupling_desc.coupled_rdevs = NULL;
56445645
}

0 commit comments

Comments
 (0)