Skip to content

Commit

Permalink
aio: prevent double free in ioctx_alloc
Browse files Browse the repository at this point in the history
ioctx_alloc() calls aio_setup_ring() to allocate a ring. If aio_setup_ring()
fails to do so it would call aio_free_ring() before returning, but
ioctx_alloc() would call aio_free_ring() again causing a double free of
the ring.

This is easily reproducible from userspace.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
  • Loading branch information
Sasha Levin authored and Benjamin LaHaise committed Nov 19, 2013
1 parent 13fd8a5 commit d558023
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
err_cleanup:
aio_nr_sub(ctx->max_reqs);
err:
aio_free_ring(ctx);
free_percpu(ctx->cpu);
free_percpu(ctx->reqs.pcpu_count);
free_percpu(ctx->users.pcpu_count);
Expand Down

0 comments on commit d558023

Please sign in to comment.