diff options
| author | Qianfeng Rong <rongqianfeng@vivo.com> | 2025-08-21 21:41:16 +0800 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@kernel.org> | 2025-08-22 06:26:22 -0700 |
| commit | 3e15cccf3ea272ae40942e8a5a741bb69a56f654 (patch) | |
| tree | c11c9d20de2eb48a5b55c6558de3143cc3f50ce9 /kernel | |
| parent | rcutorture: Delay forward-progress testing until boot completes (diff) | |
| download | linux-3e15cccf3ea272ae40942e8a5a741bb69a56f654.tar.gz linux-3e15cccf3ea272ae40942e8a5a741bb69a56f654.zip | |
rcutorture: Use kcalloc() instead of kzalloc()
Use kcalloc() in rcu_torture_writer() to gain built-in overflow protection,
making memory allocation safer when calculating allocation size compared to
explicit multiplication.
Change sizeof(ulo[0]) and sizeof(rgo[0]) to sizeof(*ulo) and sizeof(*rgo),
as this is more consistent with coding conventions.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/rcu/rcutorture.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index b8a684459381..29fe3c01312f 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -1572,12 +1572,12 @@ rcu_torture_writer(void *arg) return 0; } if (cur_ops->poll_active > 0) { - ulo = kzalloc(cur_ops->poll_active * sizeof(ulo[0]), GFP_KERNEL); + ulo = kcalloc(cur_ops->poll_active, sizeof(*ulo), GFP_KERNEL); if (!WARN_ON(!ulo)) ulo_size = cur_ops->poll_active; } if (cur_ops->poll_active_full > 0) { - rgo = kzalloc(cur_ops->poll_active_full * sizeof(rgo[0]), GFP_KERNEL); + rgo = kcalloc(cur_ops->poll_active_full, sizeof(*rgo), GFP_KERNEL); if (!WARN_ON(!rgo)) rgo_size = cur_ops->poll_active_full; } |
