On Wed, May 20, 2026 at 03:16:32PM +0800, Can Peng wrote:
> Replace kmalloc() with kmalloc_array() to prevent potential
> overflow, as recommended in Documentation/process/deprecated.rst.
> 
> Signed-off-by: Can Peng <[email protected]>
> ---
>  drivers/hv/mshv_root_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index bd1359eb58dd..146726cc4e9b 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -2241,7 +2241,7 @@ static int mshv_root_scheduler_init(unsigned int cpu)
>       outputarg = (void **)this_cpu_ptr(root_scheduler_output);
>  
>       /* Allocate two consecutive pages. One for input, one for output. */
> -     p = kmalloc(2 * HV_HYP_PAGE_SIZE, GFP_KERNEL);
> +     p = kmalloc_array(2, HV_HYP_PAGE_SIZE, GFP_KERNEL);

HV_HYP_PAGE_SIZE is a constant (4096). We don't have any dynamism in code.
There is zero potential for overflow.

That being said, I'm fine with taking this patch to stay consistent with
the document.

Thanks for your contribution.

Wei


>       if (!p)
>               return -ENOMEM;
>  
> -- 
> 2.53.0
> 

Reply via email to