* [PATCH 1/1] Drivers: hv: use kmalloc_array() instead of kmalloc()
@ 2025-11-21 3:10 Gongwei Li
2025-11-28 7:15 ` Wei Liu
0 siblings, 1 reply; 2+ messages in thread
From: Gongwei Li @ 2025-11-21 3:10 UTC (permalink / raw)
To: kys, haiyangz, wei.liu, decui; +Cc: linux-hyperv, linux-kernel, Gongwei Li
From: Gongwei Li <ligongwei@kylinos.cn>
Replace kmalloc() with kmalloc_array() to prevent potential
overflow, as recommended in Documentation/process/deprecated.rst.
Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>
---
drivers/hv/hv_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index 36ee89c0358b..7e9c8e169c66 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -586,7 +586,7 @@ static int util_probe(struct hv_device *dev,
(struct hv_util_service *)dev_id->driver_data;
int ret;
- srv->recv_buffer = kmalloc(HV_HYP_PAGE_SIZE * 4, GFP_KERNEL);
+ srv->recv_buffer = kmalloc_array(4, HV_HYP_PAGE_SIZE, GFP_KERNEL);
if (!srv->recv_buffer)
return -ENOMEM;
srv->channel = dev->channel;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] Drivers: hv: use kmalloc_array() instead of kmalloc()
2025-11-21 3:10 [PATCH 1/1] Drivers: hv: use kmalloc_array() instead of kmalloc() Gongwei Li
@ 2025-11-28 7:15 ` Wei Liu
0 siblings, 0 replies; 2+ messages in thread
From: Wei Liu @ 2025-11-28 7:15 UTC (permalink / raw)
To: Gongwei Li
Cc: kys, haiyangz, wei.liu, decui, linux-hyperv, linux-kernel,
Gongwei Li
On Fri, Nov 21, 2025 at 11:10:41AM +0800, Gongwei Li wrote:
> From: Gongwei Li <ligongwei@kylinos.cn>
>
> Replace kmalloc() with kmalloc_array() to prevent potential
> overflow, as recommended in Documentation/process/deprecated.rst.
>
> Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>
Applied to hyperv-next. Thanks.
> ---
> drivers/hv/hv_util.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
> index 36ee89c0358b..7e9c8e169c66 100644
> --- a/drivers/hv/hv_util.c
> +++ b/drivers/hv/hv_util.c
> @@ -586,7 +586,7 @@ static int util_probe(struct hv_device *dev,
> (struct hv_util_service *)dev_id->driver_data;
> int ret;
>
> - srv->recv_buffer = kmalloc(HV_HYP_PAGE_SIZE * 4, GFP_KERNEL);
> + srv->recv_buffer = kmalloc_array(4, HV_HYP_PAGE_SIZE, GFP_KERNEL);
> if (!srv->recv_buffer)
> return -ENOMEM;
> srv->channel = dev->channel;
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-28 7:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 3:10 [PATCH 1/1] Drivers: hv: use kmalloc_array() instead of kmalloc() Gongwei Li
2025-11-28 7:15 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox