[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210831181505.1074767-2-kari.argillander@gmail.com>
Date: Tue, 31 Aug 2021 21:15:01 +0300
From: Kari Argillander <kari.argillander@...il.com>
To: Konstantin Komarov <almaz.alexandrovich@...agon-software.com>,
ntfs3@...ts.linux.dev
Cc: Kari Argillander <kari.argillander@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/5] fs/ntfs3: Use kmalloc_array over kmalloc with multiply
If we do not use kmalloc_array we get checkpatch warning. It is also
little safer if something goes wrong with coding.
Signed-off-by: Kari Argillander <kari.argillander@...il.com>
---
fs/ntfs3/bitmap.c | 2 +-
fs/ntfs3/index.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c
index 831501555009..aa0b1ea66cd0 100644
--- a/fs/ntfs3/bitmap.c
+++ b/fs/ntfs3/bitmap.c
@@ -1331,7 +1331,7 @@ int wnd_extend(struct wnd_bitmap *wnd, size_t new_bits)
new_last = wbits;
if (new_wnd != wnd->nwnd) {
- new_free = kmalloc(new_wnd * sizeof(u16), GFP_NOFS);
+ new_free = kmalloc_array(new_wnd, sizeof(u16), GFP_NOFS);
if (!new_free)
return -ENOMEM;
diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 0daca9adc54c..7676a4a657d5 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -685,7 +685,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
if (end > 0x10000)
goto next;
- offs = kmalloc(sizeof(u16) * nslots, GFP_NOFS);
+ offs = kmalloc_array(nslots, sizeof(u16), GFP_NOFS);
if (!offs)
goto next;
@@ -707,7 +707,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
u16 *ptr;
int new_slots = ALIGN(2 * nslots, 8);
- ptr = kmalloc(sizeof(u16) * new_slots, GFP_NOFS);
+ ptr = kmalloc_array(new_slots, sizeof(u16), GFP_NOFS);
if (ptr)
memcpy(ptr, offs, sizeof(u16) * max_idx);
kfree(offs);
--
2.25.1
Powered by blists - more mailing lists