Skip to content

Commit

Permalink
aio: fix potential leak in aio_run_iocb().
Browse files Browse the repository at this point in the history
iovec should be reclaimed whenever caller of rw_copy_check_uvector() returns,
but it doesn't hold when failure happens right after aio_setup_vectored_rw().

Fix that in a such way to avoid hairy goto.

Signed-off-by: Leon Yu <[email protected]>
Signed-off-by: Benjamin LaHaise <[email protected]>
Cc: [email protected]
  • Loading branch information
clyu authored and bcrl committed May 1, 2014
1 parent e02ba72 commit 754320d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,10 +1327,8 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
&iovec, compat)
: aio_setup_single_vector(req, rw, buf, &nr_segs,
iovec);
if (ret)
return ret;

ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes);
if (!ret)
ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes);
if (ret < 0) {
if (iovec != &inline_vec)
kfree(iovec);
Expand Down

0 comments on commit 754320d

Please sign in to comment.