Skip to content

Commit 812a1c3

Browse files
urezkiFrederic Weisbecker
authored andcommitted
rcuscale: Do a proper cleanup if kfree_scale_init() fails
A static analyzer for C, Smatch, reports and triggers below warnings: kernel/rcu/rcuscale.c:1215 rcu_scale_init() warn: inconsistent returns 'global &fullstop_mutex'. The checker complains about, we do not unlock the "fullstop_mutex" mutex, in case of hitting below error path: <snip> ... if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) { pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n"); WARN_ON_ONCE(1); return -1; ^^^^^^^^^^ ... <snip> it happens because "-1" is returned right away instead of doing a proper unwinding. Fix it by jumping to "unwind" label instead of returning -1. Reported-by: Dan Carpenter <[email protected]> Reviewed-by: Paul E. McKenney <[email protected]> Reviewed-by: Neeraj Upadhyay <[email protected]> Closes: https://lore.kernel.org/rcu/ZxfTrHuEGtgnOYWp@pc636/T/ Fixes: 084e04f ("rcuscale: Add laziness and kfree tests") Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]>
1 parent 80e935c commit 812a1c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/rcu/rcuscale.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,13 +890,15 @@ kfree_scale_init(void)
890890
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start < 2 * HZ)) {
891891
pr_alert("ERROR: call_rcu() CBs are not being lazy as expected!\n");
892892
WARN_ON_ONCE(1);
893-
return -1;
893+
firsterr = -1;
894+
goto unwind;
894895
}
895896

896897
if (WARN_ON_ONCE(jiffies_at_lazy_cb - jif_start > 3 * HZ)) {
897898
pr_alert("ERROR: call_rcu() CBs are being too lazy!\n");
898899
WARN_ON_ONCE(1);
899-
return -1;
900+
firsterr = -1;
901+
goto unwind;
900902
}
901903
}
902904

0 commit comments

Comments
 (0)