[RH7] ploop: Fix discard iocb leak

Submitted by Kirill Tkhai on Aug. 3, 2020, 10:55 a.m.

Details

Message ID 159645214643.639951.9193715298157442844.stgit@localhost.localdomain
State New
Series "ploop: Fix discard iocb leak"
Headers show

Commit Message

Kirill Tkhai Aug. 3, 2020, 10:55 a.m.
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@virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

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);