Skip to content

Commit

Permalink
fs/ntfs3: Use kcalloc/kmalloc_array over kzalloc/kmalloc
Browse files Browse the repository at this point in the history
Use kcalloc/kmalloc_array over kzalloc/kmalloc when we allocate array.
Checkpatch found these after we did not use our own defined allocation
wrappers.

Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Kari Argillander <[email protected]>
Signed-off-by: Konstantin Komarov <[email protected]>
  • Loading branch information
teksturi authored and aalexandrovich committed Aug 27, 2021
1 parent 195c52b commit 345482b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fs/ntfs3/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ int wnd_init(struct wnd_bitmap *wnd, struct super_block *sb, size_t nbits)
if (!wnd->bits_last)
wnd->bits_last = wbits;

wnd->free_bits = kzalloc(wnd->nwnd * sizeof(u16), GFP_NOFS);
wnd->free_bits = kcalloc(wnd->nwnd, sizeof(u16), GFP_NOFS);
if (!wnd->free_bits)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs3/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = kmalloc_array(pages_per_frame, sizeof(struct page *), GFP_NOFS);
if (!pages)
return -ENOMEM;

Expand Down
7 changes: 3 additions & 4 deletions fs/ntfs3/frecord.c
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,7 @@ int ni_readpage_cmpr(struct ntfs_inode *ni, struct page *page)
idx = (vbo - frame_vbo) >> PAGE_SHIFT;

pages_per_frame = frame_size >> PAGE_SHIFT;
pages = kzalloc(pages_per_frame * sizeof(struct page *), GFP_NOFS);
pages = kcalloc(pages_per_frame, sizeof(struct page *), GFP_NOFS);
if (!pages) {
err = -ENOMEM;
goto out;
Expand Down Expand Up @@ -2137,7 +2137,7 @@ int ni_decompress_file(struct ntfs_inode *ni)
frame_bits = ni_ext_compress_bits(ni);
frame_size = 1u << frame_bits;
pages_per_frame = frame_size >> PAGE_SHIFT;
pages = kzalloc(pages_per_frame * sizeof(struct page *), GFP_NOFS);
pages = kcalloc(pages_per_frame, sizeof(struct page *), GFP_NOFS);
if (!pages) {
err = -ENOMEM;
goto out;
Expand Down Expand Up @@ -2709,8 +2709,7 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages,
goto out;
}

pages_disk = kzalloc(pages_per_frame * sizeof(struct page *),
GFP_NOFS);
pages_disk = kcalloc(pages_per_frame, sizeof(struct page *), GFP_NOFS);
if (!pages_disk) {
err = -ENOMEM;
goto out;
Expand Down

0 comments on commit 345482b

Please sign in to comment.