io_uring: set ctx sq/cq entry count earlier
authorJens Axboe <axboe@kernel.dk>
Wed, 5 Aug 2020 18:58:23 +0000 (12:58 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Aug 2020 06:24:15 +0000 (08:24 +0200)
commit6152c035f87821b3150d2c302f3f38b498e54ebe
tree679619c863c4483e68de9707595414e9cab86585
parent7387ad86fe8ef830e88a586b021b322eef316211
io_uring: set ctx sq/cq entry count earlier

commit bd74048108c179cea0ff52979506164c80f29da7 upstream.

If we hit an earlier error path in io_uring_create(), then we will have
accounted memory, but not set ctx->{sq,cq}_entries yet. Then when the
ring is torn down in error, we use those values to unaccount the memory.

Ensure we set the ctx entries before we're able to hit a potential error
path.

Cc: stable@vger.kernel.org
Reported-by: Tomáš Chaloupka <chalucha@gmail.com>
Tested-by: Tomáš Chaloupka <chalucha@gmail.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c