All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Zorro Lang <zlang@redhat.com>
Cc: fstests@vger.kernel.org, io-uring@vger.kernel.org
Subject: Re: [PATCH v4 3/5] fsstress: fix memory leak in do_aio_rw
Date: Tue, 8 Sep 2020 14:35:22 -0400	[thread overview]
Message-ID: <20200908183522.GC737175@bfoster> (raw)
In-Reply-To: <20200906175513.17595-4-zlang@redhat.com>

On Mon, Sep 07, 2020 at 01:55:11AM +0800, Zorro Lang wrote:
> If io_submit or io_getevents fails, the do_aio_rw() won't free the
> "buf" and cause memory leak.
> 
> Signed-off-by: Zorro Lang <zlang@redhat.com>
> ---
>  ltp/fsstress.c | 39 +++++++++++++++++++--------------------
>  1 file changed, 19 insertions(+), 20 deletions(-)
> 
> diff --git a/ltp/fsstress.c b/ltp/fsstress.c
> index b4a51376..c0e587a3 100644
> --- a/ltp/fsstress.c
> +++ b/ltp/fsstress.c
...
> @@ -2166,27 +2166,26 @@ do_aio_rw(int opno, long r, int flags)
>  		if (v)
>  			printf("%d/%d: %s - io_submit failed %d\n",
>  			       procid, opno, iswrite ? "awrite" : "aread", e);
> -		free_pathname(&f);
> -		close(fd);
> -		return;
> +		goto aio_out;
>  	}
>  	if ((e = io_getevents(io_ctx, 1, 1, &event, NULL)) != 1) {
>  		if (v)
>  			printf("%d/%d: %s - io_getevents failed %d\n",
>  			       procid, opno, iswrite ? "awrite" : "aread", e);
> -		free_pathname(&f);
> -		close(fd);
> -		return;
> +		goto aio_out;
>  	}
>  
>  	e = event.res != len ? event.res2 : 0;
> -	free(buf);
>  	if (v)
>  		printf("%d/%d: %s %s%s [%lld,%d] %d\n",
>  		       procid, opno, iswrite ? "awrite" : "aread",
>  		       f.path, st, (long long)off, (int)len, e);
> + aio_out:
> +	if (buf)
> +		free(buf);
> +	if (fd > 0)
> +		close(fd);

Same nit here as patch 1. Otherwise LGTM:

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  	free_pathname(&f);
> -	close(fd);
>  }
>  #endif
>  
> -- 
> 2.20.1
> 


  reply	other threads:[~2020-09-08 18:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-06 17:55 [PATCH v4 0/5] fsstress,fsx: add io_uring test and do some fix Zorro Lang
2020-09-06 17:55 ` [PATCH v4 1/5] fsstress: add IO_URING read and write operations Zorro Lang
2020-09-08 18:34   ` Brian Foster
2020-09-06 17:55 ` [PATCH v4 2/5] fsstress: reduce the number of events when io_setup Zorro Lang
2020-09-08 18:34   ` Brian Foster
2020-09-06 17:55 ` [PATCH v4 3/5] fsstress: fix memory leak in do_aio_rw Zorro Lang
2020-09-08 18:35   ` Brian Foster [this message]
2020-09-06 17:55 ` [PATCH v4 4/5] fsx: introduce fsx_rw to combine aio_rw with general read and write Zorro Lang
2020-09-08 18:35   ` Brian Foster
2020-09-06 17:55 ` [PATCH v4 5/5] fsx: add IO_URING test Zorro Lang
2020-09-08 18:36   ` Brian Foster
2020-09-09  3:58     ` Zorro Lang

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=20200908183522.GC737175@bfoster \
    --to=bfoster@redhat.com \
    --cc=fstests@vger.kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=zlang@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.