[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNNzFykVmjM+P_1JWc=39cf7LPuYsp0ds0_HQBCzR+xOvQ@mail.gmail.com>
Date: Thu, 21 Nov 2024 15:04:04 +0100
From: Marco Elver <elver@...gle.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: kasan-dev@...glegroups.com, linux-kernel@...r.kernel.org,
Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [PATCH v1 1/1] kcsan: debugfs: Use krealloc_array() to replace krealloc()
On Thu, 21 Nov 2024 at 14:58, Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> Use krealloc_array() to replace krealloc() with multiplication.
> krealloc_array() has multiply overflow check, which will be safer.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Reviewed-by: Marco Elver <elver@...gle.com>
Do you have a tree to take this through? Otherwise I'll take it.
> ---
> 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
>
Powered by blists - more mailing lists