LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Kari Argillander <kari.argillander@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	ntfs3@lists.linux.dev, Christoph Hellwig <hch@lst.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] fs/ntfs3: Use kcalloc/kmalloc_array over kzalloc/kmalloc
Date: Wed, 18 Aug 2021 02:43:59 +0300	[thread overview]
Message-ID: <20210817234359.o3cotsqpy2cg67pu@kari-VirtualBox> (raw)
In-Reply-To: <ef1d002a0720ace0ed8dd79c2ac3c600@perches.com>

On Tue, Aug 17, 2021 at 04:12:08PM -0700, Joe Perches wrote:
> On 2021-08-17 12:38, Kari Argillander wrote:
> > Use kcalloc/kmalloc_array over kzalloc/kmalloc when we allocate array.
> > Checkpatch found these after we did not use our own defined allocation
> > wrappers.
> []
> > diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> []
> > @@ -900,7 +900,7 @@ static ssize_t ntfs_compress_write(struct kiocb
> > *iocb, struct iov_iter *from)
> >  		return -EOPNOTSUPP;
> >  	}
> > 
> > -	pages = kmalloc(pages_per_frame * sizeof(struct page *), GFP_NOFS);
> > +	pages = kcalloc(pages_per_frame, sizeof(struct page *), GFP_NOFS);
> 
> This is not an exact transformation.
> This allocates zeroed memory.
> Use kmalloc_array here instead.

Yeah. Thank you so much. I actually use kmalloc_array, but mistakes were
made and this was result. Thank you for reviewing.


      reply	other threads:[~2021-08-17 23:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 19:38 [PATCH v2] Use kernel alloc wrappers and fix wargings Kari Argillander
2021-08-17 19:38 ` [PATCH v2] fs/ntfs3: Fix one none utf8 char in source file Kari Argillander
2021-08-17 19:38 ` [PATCH v2] fs/ntfs3: Do not use driver own alloc wrappers Kari Argillander
2021-08-17 19:38 ` [PATCH v2] fs/ntfs3: Use kcalloc/kmalloc_array over kzalloc/kmalloc Kari Argillander
2021-08-17 23:12   ` Joe Perches
2021-08-17 23:43     ` Kari Argillander [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=20210817234359.o3cotsqpy2cg67pu@kari-VirtualBox \
    --to=kari.argillander@gmail.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=hch@lst.de \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --subject='Re: [PATCH v2] fs/ntfs3: Use kcalloc/kmalloc_array over kzalloc/kmalloc' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).