mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: Ethan Carter Edwards <ethan@ethancedwards.com>,
	"manoj@linux.ibm.com" <manoj@linux.ibm.com>
Cc: "linux-hardening@vger.kernel.org"
	<linux-hardening@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	Uma Krishnan <ukrishn@linux.ibm.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Arnd Bergmann <arnd@arndb.de>, Al Viro <viro@zeniv.linux.org.uk>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scsi: cxlflash: change kzalloc to kcalloc
Date: Mon, 20 Jan 2025 17:16:13 +0000	[thread overview]
Message-ID: <17cbbae6-0b05-4ea3-af04-4db43c40654a@wdc.com> (raw)
In-Reply-To: <20250120165411.32256-1-ethan@ethancedwards.com>

On 20.01.25 17:55, Ethan Carter Edwards wrote:
> We are replacing any instances of kzalloc(size * count, ...) with
> kcalloc(count, size, ...) due to risk of overflow [1].
> 
> [1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
> 
> Link: https://github.com/KSPP/linux/issues/162
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> ---
>   drivers/scsi/cxlflash/superpipe.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/cxlflash/superpipe.c b/drivers/scsi/cxlflash/superpipe.c
> index b375509d1470..fc26e62e0dbf 100644
> --- a/drivers/scsi/cxlflash/superpipe.c
> +++ b/drivers/scsi/cxlflash/superpipe.c
> @@ -785,8 +785,8 @@ static struct ctx_info *create_context(struct cxlflash_cfg *cfg)
>   	struct sisl_rht_entry *rhte;
>   
>   	ctxi = kzalloc(sizeof(*ctxi), GFP_KERNEL);
> -	lli = kzalloc((MAX_RHT_PER_CONTEXT * sizeof(*lli)), GFP_KERNEL);
> -	ws = kzalloc((MAX_RHT_PER_CONTEXT * sizeof(*ws)), GFP_KERNEL);
> +	lli = kcalloc(MAX_RHT_PER_CONTEXT, sizeof(*lli), GFP_KERNEL);
> +	ws = kcalloc(MAX_RHT_PER_CONTEXT, sizeof(*ws), GFP_KERNEL);
>   	if (unlikely(!ctxi || !lli || !ws)) {
>   		dev_err(dev, "%s: Unable to allocate context\n", __func__);
>   		goto err;

JFYI, that driver is deprecated and scheduled for removal by it's maintainers:

https://lore.kernel.org/linux-scsi/20241210054055.144813-3-ajd@linux.ibm.com/

      reply	other threads:[~2025-01-20 17:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20 16:53 Ethan Carter Edwards
2025-01-20 17:16 ` Johannes Thumshirn [this message]

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=17cbbae6-0b05-4ea3-af04-4db43c40654a@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=arnd@arndb.de \
    --cc=ethan@ethancedwards.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manoj@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=ukrishn@linux.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    /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®