Skip to content

Commit 2ced704

Browse files
qianfengronggregkh
authored andcommitted
crypto: qat - use kcalloc() in qat_uclo_map_objs_from_mof()
[ Upstream commit 4c634b6 ] 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. Similarly, use size_add() instead of explicit addition for 'uobj_chunk_num + sobj_chunk_num'. Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments #1 Signed-off-by: Qianfeng Rong <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Giovanni Cabiddu <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent bc2b881 commit 2ced704

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/crypto/intel/qat/qat_common/qat_uclo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ static int qat_uclo_map_objs_from_mof(struct icp_qat_mof_handle *mobj_handle)
17461746
if (sobj_hdr)
17471747
sobj_chunk_num = sobj_hdr->num_chunks;
17481748

1749-
mobj_hdr = kzalloc((uobj_chunk_num + sobj_chunk_num) *
1749+
mobj_hdr = kcalloc(size_add(uobj_chunk_num, sobj_chunk_num),
17501750
sizeof(*mobj_hdr), GFP_KERNEL);
17511751
if (!mobj_hdr)
17521752
return -ENOMEM;

0 commit comments

Comments
 (0)