Fix missing mutex unlock in rv_register_monitor()
Subsystems (2)
PATCH 1/1 Fix missing mutex unlock in rv_register_monitor()
If create_monitor_dir() fails, the function returns directly without releasing rv_interface_lock. This leaves the mutex locked and causes subsequent monitor registration attempts to deadlock.
Fix it by making the error path jump to out_unlock, ensuring that the mutex is always released before returning.
--- kernel/trace/rv/rv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/rv/rv.c +1 -1
@@ -805,7 +805,7 @@ int rv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent) retval =create_monitor_dir (monitor, parent);if (retval) -return retval; + goto out_unlock;/* keep children close to the parent for easier visualisation */ if (parent)
Signature · 1 line
2.20.1
Quoted 10 lines · Zhen Ni
If
create_monitor_dir()fails, the function returns directly without releasingrv_interface_lock. This leaves the mutex locked and causes subsequent monitor registration attempts to deadlock.Fix it by making the error path jump to
out_unlock, ensuring that the mutex is always released before returning.Fixes 24cbfe18d55a ("rv: Merge struct rv_monitor_def into struct
rv_monitor")Signed-off-by Zhen Ni <[email protected]>
Good catch, thank you!
I would also add a:
(Adding Nam to the loop, as author of that patch)
Thanks,
Gabriele
Quoted 19 lines
---
kernel/trace/rv/rv.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/trace/rv/rv.c +0
-0@@ -805,7 +805,7 @@ int rv_register_monitor(struct rv_monitor *monitor, struct rv_monitor *parent)
retval =create_monitor_dir(monitor, parent); if (retval)kernel/trace/rv/rv.c +1
-1-return retval; + goto out_unlock;
/* keep children close to the parent for easier visualisation */
if (parent)
Nam Cao
Reviewed-byQuoted 12 lines · Gabriele Monaco
Quoted 10 lines · Zhen Ni
If
create_monitor_dir()fails, the function returns directly without releasingrv_interface_lock. This leaves the mutex locked and causes subsequent monitor registration attempts to deadlock.Fix it by making the error path jump to
out_unlock, ensuring that the mutex is always released before returning.Fixes 24cbfe18d55a ("rv: Merge struct rv_monitor_def into struct
rv_monitor")Signed-off-by Zhen Ni <[email protected]>
Quoted 7 lines
Good catch, thank you!
Reviewed-by Gabriele Monaco <[email protected]>I would also add a:
Fixes 24cbfe18d55a ("rv: Merge struct rv_monitor_def into struct rv_monitor")
Am I hallucinating, or the fix tag is already there?
Quoted 1 line
(Adding Nam to the loop, as author of that patch)
Thanks for CC!
I have been debating whether we should convert rv to use lock guard. Problem like this one is a good advocate.
Nam
Gabriele Monaco
maintainerQuoted 1 line · Nam Cao
Am I hallucinating, or the fix tag is already there?
I should stop doing 3 things at the same time, my bad :')
Quoted 9 lines
Quoted 2 lines
(Adding Nam to the loop, as author of that patch)
Thanks for CC!
Reviewed-by Nam Cao <[email protected]>I have been debating whether we should convert rv to use lock guard. Problem like this one is a good advocate.
I'm totally in favour, next cleanup series let's say.
Thanks,
Gabriele