mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Su Hui <suhui@nfschina.com>
Cc: dave@stgolabs.net, josh@joshtriplett.org, frederic@kernel.org,
	neeraj.upadhyay@kernel.org, joel@joelfernandes.org,
	boqun.feng@gmail.com, urezki@gmail.com, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
	qiang.zhang1211@gmail.com, linux-kernel@vger.kernel.org,
	rcu@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] rcuscale: using kcalloc() to relpace kmalloc()
Date: Tue, 22 Apr 2025 10:58:02 -0700	[thread overview]
Message-ID: <ae61d78a-e950-41e1-9a2c-afac2a385156@paulmck-laptop> (raw)
In-Reply-To: <20250422015144.2012708-1-suhui@nfschina.com>

On Tue, Apr 22, 2025 at 09:51:45AM +0800, Su Hui wrote:
> It's safer to using kcalloc() because it can prevent overflow
> problem.
> 
> Signed-off-by: Su Hui <suhui@nfschina.com>

Reviewed-by: Paul E. McKenney <paulmck@kernel.org>

> ---
> v2: 
>  - using kcalloc rather than kmalloc_array().
> v1:
>  - https://lore.kernel.org/all/20250421061508.718752-1-suhui@nfschina.com/
> 
>  kernel/rcu/rcuscale.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
> index 0f3059b1b80d..b521d0455992 100644
> --- a/kernel/rcu/rcuscale.c
> +++ b/kernel/rcu/rcuscale.c
> @@ -762,7 +762,7 @@ kfree_scale_thread(void *arg)
>  		}
>  
>  		for (i = 0; i < kfree_alloc_num; i++) {
> -			alloc_ptr = kmalloc(kfree_mult * sizeof(struct kfree_obj), GFP_KERNEL);
> +			alloc_ptr = kcalloc(kfree_mult, sizeof(struct kfree_obj), GFP_KERNEL);
>  			if (!alloc_ptr)
>  				return -ENOMEM;
>  
> -- 
> 2.30.2
> 

  reply	other threads:[~2025-04-22 17:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21  6:15 [PATCH] rcuscale: using kmalloc_array() " Su Hui
2025-04-21 13:49 ` Paul E. McKenney
2025-04-22  1:37   ` Su Hui
2025-04-22  1:51 ` [PATCH v2] rcuscale: using kcalloc() " Su Hui
2025-04-22 17:58   ` Paul E. McKenney [this message]
2025-04-22 22:55     ` Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae61d78a-e950-41e1-9a2c-afac2a385156@paulmck-laptop \
    --to=paulmck@kernel.org \
    --cc=boqun.feng@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=frederic@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=qiang.zhang1211@gmail.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=suhui@nfschina.com \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®