From: Kari Argillander <kari.argillander@gmail.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
ntfs3@lists.linux.dev
Cc: Kari Argillander <kari.argillander@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] fs/ntfs3: Use kmalloc_array over kmalloc with multiply
Date: Tue, 31 Aug 2021 21:15:01 +0300 [thread overview]
Message-ID: <20210831181505.1074767-2-kari.argillander@gmail.com> (raw)
In-Reply-To: <20210831181505.1074767-1-kari.argillander@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2021-08-31 18:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-31 18:15 [PATCH 0/5] fs/ntfs3: Fix various styling issues Kari Argillander
2021-08-31 18:15 ` Kari Argillander [this message]
2021-09-01 2:40 ` [PATCH 1/5] fs/ntfs3: Use kmalloc_array over kmalloc with multiply Joe Perches
2021-09-01 13:24 ` Kari Argillander
2021-09-02 14:03 ` David Laight
2021-08-31 18:15 ` [PATCH 2/5] fs/ntfs3: Use consistent spacing around '+' Kari Argillander
2021-09-02 4:22 ` Joe Perches
2021-09-02 8:10 ` Kari Argillander
2021-09-07 16:23 ` Konstantin Komarov
2021-09-07 16:25 ` Kari Argillander
2021-08-31 18:15 ` [PATCH 3/5] fs/ntfs3: Place Comparisons constant right side of the test Kari Argillander
2021-08-31 18:15 ` [PATCH 4/5] fs/ntfs3: Remove braces from single statment block Kari Argillander
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=20210831181505.1074767-2-kari.argillander@gmail.com \
--to=kari.argillander@gmail.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox