lkml.org 
[lkml]   [2021]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] fs/ntfs3: Use kcalloc/kmalloc_array over kzalloc/kmalloc
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.

\
 
 \ /
  Last update: 2021-08-18 01:13    [W:0.054 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site