mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Praveen Kumar <kpraveen.lkml@gmail.com>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>, kys@microsoft.com
Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools/hv: Add memory allocation check in hv_fcopy_start
Date: Wed, 28 Aug 2024 15:48:50 +0530	[thread overview]
Message-ID: <d95656fd-cd64-4386-a22f-689a70d8327c@gmail.com> (raw)
In-Reply-To: <20240828100031.3833-1-zhujun2@cmss.chinamobile.com>

On 28/08/24 15:30, Zhu Jun wrote:
> Added checks for `file_name` and `path_name` memory allocation failures,
> with error logging and process exit on failure.
> 
> Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
> ---
>   tools/hv/hv_fcopy_uio_daemon.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/tools/hv/hv_fcopy_uio_daemon.c b/tools/hv/hv_fcopy_uio_daemon.c
> index 3ce316cc9f97..2efdf8d28e9c 100644
> --- a/tools/hv/hv_fcopy_uio_daemon.c
> +++ b/tools/hv/hv_fcopy_uio_daemon.c
> @@ -295,6 +295,10 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in)
>   
>   	file_name = (char *)malloc(file_size * sizeof(char));
>   	path_name = (char *)malloc(path_size * sizeof(char));
> +	if (!file_name || !path_name) {
> +		syslog(LOG_ERR, "Can't allocate memory!");

Probably, you may want to cleanup memory here in case either of one is 
successful allocation.

> +		exit(EXIT_FAILURE);
> +	}
>   
>   	wcstoutf8(file_name, (__u16 *)in_file_name, file_size);
>   	wcstoutf8(path_name, (__u16 *)in_path_name, path_size);


      reply	other threads:[~2024-08-28 10:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 10:00 Zhu Jun
2024-08-28 10:18 ` Praveen Kumar [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=d95656fd-cd64-4386-a22f-689a70d8327c@gmail.com \
    --to=kpraveen.lkml@gmail.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wei.liu@kernel.org \
    --cc=zhujun2@cmss.chinamobile.com \
    /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

all inboxes | Powered by JetHome®