Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4444d852 authored by Paul E. McKenney's avatar Paul E. McKenney
Browse files

rcutorture: Check nfakewriters parameter



Currently, a negative value for rcutorture.nfakewriters= can cause
rcutorture to pass a negative size to the memory allocator, which
is not really a particularly good thing to do.  This commit therefore
adds bounds checking to this parameter, so that values that are less
than or equal to zero disable fake writing.

Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
parent d9eba768
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -1786,13 +1786,16 @@ rcu_torture_init(void)
					  writer_task);
	if (firsterr)
		goto unwind;
	fakewriter_tasks = kzalloc(nfakewriters * sizeof(fakewriter_tasks[0]),
	if (nfakewriters > 0) {
		fakewriter_tasks = kzalloc(nfakewriters *
					   sizeof(fakewriter_tasks[0]),
					   GFP_KERNEL);
		if (fakewriter_tasks == NULL) {
			VERBOSE_TOROUT_ERRSTRING("out of memory");
			firsterr = -ENOMEM;
			goto unwind;
		}
	}
	for (i = 0; i < nfakewriters; i++) {
		firsterr = torture_create_kthread(rcu_torture_fakewriter,
						  NULL, fakewriter_tasks[i]);