From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org
Cc: Marco Elver <elver@google.com>, Dmitry Vyukov <dvyukov@google.com>
Subject: [PATCH v2 1/2] kcsan: debugfs: Use krealloc_array() to replace krealloc()
Date: Thu, 21 Nov 2024 16:12:51 +0200 [thread overview]
Message-ID: <20241121141412.107370-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20241121141412.107370-1-andriy.shevchenko@linux.intel.com>
Use krealloc_array() to replace krealloc() with multiplication.
krealloc_array() has multiply overflow check, which will be safer.
Reviewed-by: Marco Elver <elver@google.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
kernel/kcsan/debugfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/kcsan/debugfs.c b/kernel/kcsan/debugfs.c
index 53b21ae30e00..be7051d0e7f4 100644
--- a/kernel/kcsan/debugfs.c
+++ b/kernel/kcsan/debugfs.c
@@ -166,10 +166,10 @@ static ssize_t insert_report_filterlist(const char *func)
} else if (report_filterlist.used == report_filterlist.size) {
/* resize filterlist */
size_t new_size = report_filterlist.size * 2;
- unsigned long *new_addrs =
- krealloc(report_filterlist.addrs,
- new_size * sizeof(unsigned long), GFP_ATOMIC);
+ unsigned long *new_addrs;
+ new_addrs = krealloc_array(report_filterlist.addrs,
+ new_size, sizeof(*new_addrs), GFP_ATOMIC);
if (new_addrs == NULL) {
/* leave filterlist itself untouched */
ret = -ENOMEM;
--
2.43.0.rc1.1336.g36b5255a03ac
next prev parent reply other threads:[~2024-11-21 14:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 14:12 [PATCH v2 0/2] kcsan: debugs: Refactor allocation code Andy Shevchenko
2024-11-21 14:12 ` Andy Shevchenko [this message]
2024-11-21 14:12 ` [PATCH v2 2/2] kcsan: debugfs: Use krealloc_array() for initial allocation as well Andy Shevchenko
2024-11-21 14:17 ` [PATCH v2 0/2] kcsan: debugs: Refactor allocation code Andy Shevchenko
2024-11-21 14:19 ` Marco Elver
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=20241121141412.107370-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.