diff mbox series

[-next] io_uring: Remove redundant NULL check

Message ID 1595474350-10039-1-git-send-email-liheng40@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] io_uring: Remove redundant NULL check | expand

Commit Message

Li Heng July 23, 2020, 3:19 a.m. UTC
Fix below warnings reported by coccicheck:
./fs/io_uring.c:1544:2-7: WARNING: NULL check before some freeing functions is not needed.
./fs/io_uring.c:3095:2-7: WARNING: NULL check before some freeing functions is not needed.
./fs/io_uring.c:3195:2-7: WARNING: NULL check before some freeing functions is not needed.

Signed-off-by: Li Heng <liheng40@huawei.com>
---
 fs/io_uring.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Jens Axboe July 23, 2020, 3:25 a.m. UTC | #1
On 7/22/20 9:19 PM, Li Heng wrote:
> Fix below warnings reported by coccicheck:
> ./fs/io_uring.c:1544:2-7: WARNING: NULL check before some freeing functions is not needed.
> ./fs/io_uring.c:3095:2-7: WARNING: NULL check before some freeing functions is not needed.
> ./fs/io_uring.c:3195:2-7: WARNING: NULL check before some freeing functions is not needed.

Not needed, but it's faster that way. See recent discussions on the
io-uring list. Hence they are very much on purpose, and it'd be great if
someone would ensure that kfree() was an inline that checks for non-NULL
before calling __kfree() or whatever the real function would then be.
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6587935..71ac3f7 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1540,8 +1540,7 @@  static void io_dismantle_req(struct io_kiocb *req)
 {
 	io_clean_op(req);
 
-	if (req->io)
-		kfree(req->io);
+	kfree(req->io);
 	if (req->file)
 		io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
 	io_req_clean_work(req);
@@ -3091,8 +3090,7 @@  static int io_read(struct io_kiocb *req, bool force_nonblock,
 		}
 	}
 out_free:
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
@@ -3191,8 +3189,7 @@  static int io_write(struct io_kiocb *req, bool force_nonblock,
 		}
 	}
 out_free:
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }