Linux-HyperV List
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu@kernel.org>
To: Gongwei Li <13875017792@163.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com, linux-hyperv@vger.kernel.org,
	linux-kernel@vger.kernel.org, Gongwei Li <ligongwei@kylinos.cn>
Subject: Re: [PATCH 1/1] Drivers: hv: use kmalloc_array() instead of kmalloc()
Date: Fri, 28 Nov 2025 07:15:24 +0000	[thread overview]
Message-ID: <20251128071524.GA69390@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <20251121031041.56619-1-13875017792@163.com>

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
> 

      reply	other threads:[~2025-11-28  7:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251128071524.GA69390@liuwe-devbox-debian-v2.local \
    --to=wei.liu@kernel.org \
    --cc=13875017792@163.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=ligongwei@kylinos.cn \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox