rcuscale: Do a proper cleanup if kfree_scale_init() fails
Subsystems (2)
Uladzislau Rezki (Sony)
maintainerPATCH 1/2 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.
--- kernel/rcu/rcuscale.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/rcu/rcuscale.c +2 -2
@@ -890,13 +890,13 @@ kfree_scale_init(void)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 ; + goto unwind; }if (WARN_ON_ONCE (jiffies_at_lazy_cb - jif_start >3 *HZ )) {pr_alert ("ERROR: call_rcu() CBs are being too lazy!\n" );WARN_ON_ONCE (1 ); -return -1 ; + goto unwind; } }
Signature · 1 line
2.39.5
Uladzislau Rezki (Sony)
maintainerPATCH 2/2 rcuscale: Remove redundant WARN_ON_ONCE() splat
There are two places where WARN_ON_ONCE() is called two times in the error paths. One which is encapsulated into if() condition and another one, which is unnecessary, is placed in the brackets.
Remove an extra WARN_ON_ONCE() splat which is in brackets.
--- kernel/rcu/rcuscale.c | 2 -- 1 file changed, 2 deletions(-)
kernel/rcu/rcuscale.c +0 -2
@@ -889,13 +889,11 @@ kfree_scale_init(void)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 ); goto unwind; }if (WARN_ON_ONCE (jiffies_at_lazy_cb - jif_start >3 *HZ )) {pr_alert ("ERROR: call_rcu() CBs are being too lazy!\n" ); -WARN_ON_ONCE (1 ); goto unwind; } }
Signature · 1 line
2.39.5
Re: [PATCH 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat
Quoted 7 lines · Uladzislau Rezki (Sony)
There are two places where
WARN_ON_ONCE()is called two times in the error paths. One which is encapsulated intoif()condition and another one, which is unnecessary, is placed in the brackets.Remove an extra
WARN_ON_ONCE()splat which is in brackets.Signed-off-by Uladzislau Rezki (Sony) <[email protected]>
For both:
Quoted 25 lines
--- kernel/rcu/rcuscale.c | 2 -- 1 file changed, 2 deletions(-)kernel/rcu/rcuscale.c +0
-2@@ -889,13 +889,11 @@ kfree_scale_init(void)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 ); goto unwind; }if (WARN_ON_ONCE (jiffies_at_lazy_cb - jif_start >3 *HZ )) {pr_alert ("ERROR: call_rcu() CBs are being too lazy!\n" ); -WARN_ON_ONCE (1 ); goto unwind; } }Signature · 1 line
2.39.5
Uladzislau Rezki
maintainerRe: [PATCH 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat
Quoted 5 lines · Paul E. McKenney
Quoted 4 lines · Uladzislau Rezki (Sony)
There are two places where
WARN_ON_ONCE()is called two times in the error paths. One which is encapsulated intoif()condition and another one, which is unnecessary, is placed in the brackets.
Quoted 8 lines
Quoted 3 lines
Remove an extra
WARN_ON_ONCE()splat which is in brackets.Signed-off-by Uladzislau Rezki (Sony) <[email protected]>For both:
Reviewed-by Paul E. McKenney <[email protected]>
Thank you :)
--
Uladzislau Rezki
Frederic Weisbecker
maintainerRe: [PATCH 2/2] rcuscale: Remove redundant WARN_ON_ONCE() splat
In reply to Paul E. McKenneyQuoted 5 lines · Paul E. McKenney
Quoted 4 lines · Uladzislau Rezki (Sony)
There are two places where
WARN_ON_ONCE()is called two times in the error paths. One which is encapsulated intoif()condition and another one, which is unnecessary, is placed in the brackets.
Quoted 7 lines
Quoted 3 lines
Remove an extra
WARN_ON_ONCE()splat which is in brackets.Signed-off-by Uladzislau Rezki (Sony) <[email protected]>For both:
Reviewed-by Paul E. McKenney <[email protected]>
Both applied!
Thanks.