io_uring: fix incorrect check for kvmalloc failure
Subsystems (3)
PATCH 1/1 io_uring: fix incorrect check for kvmalloc failure
From: Colin Ian King <[email protected]>
Currently imu is being allocated but the kvmalloc failure is checking imu->bvec instead of imu. Fix this by checking imu for null.
Addresses-Coverity: ("Array compared against 0")
Fixes 41edf1a5ec96 ("io_uring: keep table of pointers to ubufs")
Signed-off-by Colin Ian King <[email protected]>
--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
@@ -8269,7 +8269,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, goto done; imu =kvmalloc (struct_size (imu, bvec, nr_pages),GFP_KERNEL ); -if (!imu->bvec) +if (!imu) goto done; ret =0 ;
Signature · 1 line
2.30.2
Quoted 4 lines · Colin King
From: Colin Ian King <[email protected]>
Currently imu is being allocated but the kvmalloc failure is checking
imu->bvecinstead of imu. Fix this by checking imu for null.
Right, that's buggy.
fwiw, was reported by lkp and I sent a fix yesterday, so take any.
https://lore.kernel.org/io-uring/d28eb1bc4384284f69dbce35b9f70c115ff6176f.1619392565.git.asml.silence@gmail.com/T/#u
Quoted 22 lines
Addresses-Coverity: ("Array compared against 0")
Fixes 41edf1a5ec96 ("io_uring: keep table of pointers to ubufs")Signed-off-by Colin Ian King <[email protected]>--- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/io_uring.c +1
-1@@ -8269,7 +8269,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov, goto done; imu =kvmalloc (struct_size (imu, bvec, nr_pages),GFP_KERNEL ); -if (!imu->bvec) +if (!imu) goto done; ret =0 ;
Signature · 1 line
Pavel Begunkov