Re: [PATCH] crypto: qat - use kcalloc() in qat_uclo_map_objs_from_mof()
From: Andy Shevchenko
Date: Thu Aug 21 2025 - 09:03:35 EST
On Thu, Aug 21, 2025 at 08:35:42PM +0800, Qianfeng Rong wrote:
> As noted in the kernel documentation [1], open-coded multiplication in
> allocator arguments is discouraged because it can lead to integer overflow.
>
> Use kcalloc() to gain built-in overflow protection, making memory
> allocation safer when calculating allocation size compared to explicit
> multiplication.
> [1]: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@xxxxxxxx>
Make it a Link tag.
Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments #1
Signed-off-by: Qianfeng Rong <rongqianfeng@xxxxxxxx>
(also note no blank lines in tag block)
...
> - mobj_hdr = kzalloc((uobj_chunk_num + sobj_chunk_num) *
> + mobj_hdr = kcalloc(uobj_chunk_num + sobj_chunk_num,
size_add() ?
> sizeof(*mobj_hdr), GFP_KERNEL);
> if (!mobj_hdr)
> return -ENOMEM;
--
With Best Regards,
Andy Shevchenko