aio: fix potential leak in aio_run_iocb().

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 <chianglungyu@gmail.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
Cc: stable@vger.kernel.org
This commit is contained in:
Leon Yu 2014-05-01 03:31:28 +00:00 committed by Benjamin LaHaise
parent e02ba72aab
commit 754320d6e1
1 changed files with 2 additions and 4 deletions

View File

@ -1327,10 +1327,8 @@ static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
&iovec, compat) &iovec, compat)
: aio_setup_single_vector(req, rw, buf, &nr_segs, : aio_setup_single_vector(req, rw, buf, &nr_segs,
iovec); iovec);
if (ret) if (!ret)
return ret; ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes);
ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes);
if (ret < 0) { if (ret < 0) {
if (iovec != &inline_vec) if (iovec != &inline_vec)
kfree(iovec); kfree(iovec);