[Devel] [PATCH RH7] ploop: Fix discard iocb leak

Kirill Tkhai ktkhai at virtuozzo.com
Mon Aug 3 13:55:59 MSK 2020


Swap iocb allocation and ext4 check.

This is only used in experimental kaio over ext4 code,
and the patch *does not* require RK.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 6d6517dcf2e5..89e39ff1b926 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -181,10 +181,6 @@ static int kaio_kernel_submit(struct file *file, struct kaio_req *kreq,
 	struct iov_iter iter;
 	int err;
 
-	iocb = aio_kernel_alloc(GFP_NOIO);
-	if (!iocb)
-		return -ENOMEM;
-
 	if (rw & REQ_DISCARD) {
 		op = IOCB_CMD_UNMAP_ITER;
 		if (file_inode(file)->i_sb->s_magic == EXT4_SUPER_MAGIC)
@@ -194,6 +190,10 @@ static int kaio_kernel_submit(struct file *file, struct kaio_req *kreq,
 	else
 		op = IOCB_CMD_READ_ITER;
 
+	iocb = aio_kernel_alloc(GFP_NOIO);
+	if (!iocb)
+		return -ENOMEM;
+
 	iov_iter_init_bvec(&iter, kreq->bvecs, nr_segs, count, 0);
 	aio_kernel_init_iter(iocb, file, op, &iter, pos);
 	aio_kernel_init_callback(iocb, kaio_rw_kreq_complete, (u64)kreq);




More information about the Devel mailing list