aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorRahul Kumar <rk0006818@gmail.com>2025-11-04 17:46:18 +0530
committerWei Liu <wei.liu@kernel.org>2025-11-15 06:18:17 +0000
commit22cb2f06fac9a05455eafa3ef3dc49ed7dedb240 (patch)
treec14dfa562c67fbab950a1e27a4f5fc753aa7c4aa /drivers/hv
parent5f4b5edcb1a389b16b852fb30dcd435bfb1f8d23 (diff)
downloadtip-22cb2f06fac9a05455eafa3ef3dc49ed7dedb240.tar.gz
Drivers: hv: Use kmalloc_array() instead of kmalloc()
Documentation/process/deprecated.rst recommends against the use of kmalloc with dynamic size calculations due to the risk of overflow and smaller allocation being made than the caller was expecting. Replace kmalloc() with kmalloc_array() in hv_common.c to make the intended allocation size clearer and avoid potential overflow issues. The number of pages (pgcount) is bounded, so overflow is not a practical concern here. However, using kmalloc_array() better reflects the intent to allocate an array and improves consistency with other allocations. No functional change intended. Signed-off-by: Rahul Kumar <rk0006818@gmail.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/hv_common.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
index 5f5047f122a9f9..0a3ab7efed4681 100644
--- a/drivers/hv/hv_common.c
+++ b/drivers/hv/hv_common.c
@@ -487,7 +487,7 @@ int hv_common_cpu_init(unsigned int cpu)
* online and then taken offline
*/
if (!*inputarg) {
- mem = kmalloc(pgcount * HV_HYP_PAGE_SIZE, flags);
+ mem = kmalloc_array(pgcount, HV_HYP_PAGE_SIZE, flags);
if (!mem)
return -ENOMEM;