qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/3] tests/migration: mem leak fix


From: Alex Bennée
Subject: Re: [Qemu-devel] [PATCH 1/3] tests/migration: mem leak fix
Date: Tue, 10 Sep 2019 19:52:42 +0100
User-agent: mu4e 1.3.4; emacs 27.0.50

Mao Zhongyi <address@hidden> writes:

> Cc: address@hidden
> Cc: address@hidden
> Cc: address@hidden
>
> Signed-off-by: Mao Zhongyi <address@hidden>
> ---
>  tests/migration/stress.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tests/migration/stress.c b/tests/migration/stress.c
> index d9aa4afe92..e6c9a6b243 100644
> --- a/tests/migration/stress.c
> +++ b/tests/migration/stress.c
> @@ -181,6 +181,8 @@ static int stressone(unsigned long long ramsizeMB)
>      if (!ram) {
>          fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM: 
> %s\n",
>                  argv0, gettid(), ramsizeMB, strerror(errno));
> +        if (data)
> +            free(data);

I wonder if it's worth using the glib macros here so:

  g_autofree char *data = g_malloc(PAGE_SIZE);

and the same for ram. You can then drop the frees.

>          return -1;
>      }
>      if (!data) {


--
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]