Re: [PATCH v2] fs/ntfs3: Use kcalloc/kmalloc_array over kzalloc/kmalloc

Joe Perches
2021-08-18T00:31:16Z

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.