Unverified Commit 55df3841 authored by Qianfeng Rong's avatar Qianfeng Rong Committed by Ilpo Järvinen
Browse files

platform/x86/intel/pmc: use kcalloc() instead of kzalloc()

Replace devm_kzalloc() with devm_kcalloc() in pmc_core_get_tgl_lpm_reqs().
As noted in the kernel documentation [1], open-coded multiplication in
allocator arguments is discouraged because it can lead to integer
overflow.

Using devm_kcalloc() provides built-in overflow protection, making the
memory allocation safer when calculating the 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: default avatarQianfeng Rong <rongqianfeng@vivo.com>
Acked-by: default avatarDavid E. Box <david.e.box@intel.com>
Link: https://lore.kernel.org/r/20250819135155.338380-1-rongqianfeng@vivo.com


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 6d47b4f0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -273,7 +273,7 @@ void pmc_core_get_tgl_lpm_reqs(struct platform_device *pdev)

	addr = (u32 *)out_obj->buffer.pointer;

	lpm_req_regs = devm_kzalloc(&pdev->dev, lpm_size * sizeof(u32),
	lpm_req_regs = devm_kcalloc(&pdev->dev, lpm_size, sizeof(u32),
				    GFP_KERNEL);
	if (!lpm_req_regs)
		goto free_acpi_obj;