reset: fix refcount leak in reset_control_bulk_assert()
PATCH 1/1 reset: fix refcount leak in reset_control_bulk_assert()
When reset_control_bulk_assert() asserts a batch of reset controls, it calls reset
Fixes 0b52297f2288 ("reset: Add support for shared reset controls")
Signed-off-by WenTao Liang <[email protected]>
--- drivers/reset/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/reset/core.c +8 -1
@@ -516,8 +516,15 @@ int reset_control_assert(struct reset_control *rstc)if (WARN_ON (atomic_read (&rstc->deassert_count) ==0 ))return -EINVAL ; -if (atomic_dec_return (&rstc->deassert_count) !=0 ) +if (atomic_dec_return (&rstc->deassert_count) !=0 ) { +int err = rcdev->ops->assert (rcdev, rstc->id); + +if (err) { +atomic_inc (&rstc->deassert_count); +return err; + }return 0 ; + }/* * Shared reset controls allow the reset line to be in any state
Signature · 1 line
2.50.1 (Apple Git-155)
Philipp Zabel
maintainerQuoted 2 lines · WenTao Liang
When
reset_control_bulk_assert()asserts a batch of reset controls, it calls reset
Can you write a better commit message?
What does this patch accomplish, and why?
Quoted 11 lines
Fixes 0b52297f2288 ("reset: Add support for shared reset controls")Signed-off-by WenTao Liang <[email protected]>--- drivers/reset/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/reset/core.c +0
-0
drivers/reset/core.c int reset_control_assert(struct reset_control *rstc) · line 520
Quoted 6 lines
drivers/reset/core.c +2
-1@@ -516,8 +516,15 @@ int reset_control_assert(struct reset_control *rstc)if (WARN_ON (atomic_read (&rstc->deassert_count) ==0 ))return -EINVAL ; -if (atomic_dec_return (&rstc->deassert_count) !=0 ) +if (atomic_dec_return (&rstc->deassert_count) !=0 ) { +int err = rcdev->ops->assert (rcdev, rstc->id);
This is wrong, asserting the reset must not happen unless deassert_count has been decremented to zero.
regards
Philipp