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@xxxxxxxxxx> > --- > 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@xxxxxxxxxx> > free_pathname(&f); > - close(fd); > } > #endif > > -- > 2.20.1 >