lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdAySwLZ8gf_mDoQDX4KdC-hsCYL3VbkZSk_NSKNY5VTw@mail.gmail.com>
Date: Tue, 19 Aug 2025 12:46:14 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Qianfeng Rong <rongqianfeng@...o.com>
Cc: Jyoti Bhayana <jbhayana@...gle.com>, Jonathan Cameron <jic23@...nel.org>, 
	David Lechner <dlechner@...libre.com>, Nuno Sá <nuno.sa@...log.com>, 
	Andy Shevchenko <andy@...nel.org>, linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: common: scmi_iio: use kcalloc() instead of kzalloc()

On Tue, Aug 19, 2025 at 11:56 AM Qianfeng Rong <rongqianfeng@...o.com> wrote:
>
> Replace calls of devm_kzalloc() with devm_kcalloc() in scmi_alloc_iiodev()
> and scmi_iio_set_sampling_freq_avail() for safer memory allocation with
> built-in overflow protection.

While this change is correct...

...

>         sensor->freq_avail =
> -               devm_kzalloc(&iio_dev->dev,
> -                            sizeof(*sensor->freq_avail) *
> -                                    (sensor->sensor_info->intervals.count * 2),
> +               devm_kcalloc(&iio_dev->dev,
> +                            sensor->sensor_info->intervals.count * 2,

...I would also switch this to use array_size() instead of explicit
multiplication as it will check for boundaries that are not static in
this case.

> +                            sizeof(*sensor->freq_avail),
>                              GFP_KERNEL);
>         if (!sensor->freq_avail)
>                 return -ENOMEM;

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ