Skip to content

Commit 676e546

Browse files
committed
scftorture: Consolidate scftorture_invoke_one() check and kfree()
This commit moves checking of the ->scfc_out field and the freeing of the scf_check structure down below the end of switch statement, thus saving a few lines of code. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 34e8c48 commit 676e546

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

kernel/scftorture.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static void scf_handler_1(void *scfc_in)
289289
static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_random_state *trsp)
290290
{
291291
uintptr_t cpu;
292-
int ret;
292+
int ret = 0;
293293
struct scf_check *scfcp = NULL;
294294
struct scf_selector *scfsp = scf_sel_rand(trsp);
295295

@@ -322,11 +322,7 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
322322
else
323323
scfp->n_single_ofl++;
324324
kfree(scfcp);
325-
} else if (scfcp && scfsp->scfs_wait) {
326-
if (WARN_ON_ONCE(!scfcp->scfc_out))
327-
atomic_inc(&n_mb_out_errs); // Leak rather than trash!
328-
else
329-
kfree(scfcp);
325+
scfcp = NULL;
330326
}
331327
break;
332328
case SCF_PRIM_MANY:
@@ -341,12 +337,6 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
341337
scfcp->scfc_in = true;
342338
}
343339
smp_call_function_many(cpu_online_mask, scf_handler, scfcp, scfsp->scfs_wait);
344-
if (scfcp) {
345-
if (WARN_ON_ONCE(!scfcp->scfc_out))
346-
atomic_inc(&n_mb_out_errs); // Leak rather than trash!
347-
else
348-
kfree(scfcp);
349-
}
350340
break;
351341
case SCF_PRIM_ALL:
352342
if (scfsp->scfs_wait)
@@ -360,14 +350,14 @@ static void scftorture_invoke_one(struct scf_statistics *scfp, struct torture_ra
360350
scfcp->scfc_in = true;
361351
}
362352
smp_call_function(scf_handler, scfcp, scfsp->scfs_wait);
363-
if (scfcp) {
364-
if (WARN_ON_ONCE(!scfcp->scfc_out))
365-
atomic_inc(&n_mb_out_errs); // Leak rather than trash!
366-
else
367-
kfree(scfcp);
368-
}
369353
break;
370354
}
355+
if (scfcp && scfsp->scfs_wait) {
356+
if (WARN_ON_ONCE(!scfcp->scfc_out))
357+
atomic_inc(&n_mb_out_errs); // Leak rather than trash!
358+
else
359+
kfree(scfcp);
360+
}
371361
if (use_cpus_read_lock)
372362
cpus_read_unlock();
373363
else

0 commit comments

Comments
 (0)