public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: NULL check before kfree() is not needed
@ 2020-08-15  3:25 Wu Bo
  2020-08-15  3:39 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Wu Bo @ 2020-08-15  3:25 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, linfeilong, liuzhiqiang26, wubo40

NULL check before kfree() is not needed

Signed-off-by: Wu Bo <[email protected]>
---
 fs/io_uring.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 2a3af95..59c19c8 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1537,8 +1537,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);
@@ -3111,8 +3110,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
 		return -EAGAIN;
 	}
 out_free:
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
@@ -3210,8 +3208,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
 		return -EAGAIN;
 	}
 out_free:
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return ret;
 }
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io_uring: NULL check before kfree() is not needed
  2020-08-15  3:25 [PATCH] io_uring: NULL check before kfree() is not needed Wu Bo
@ 2020-08-15  3:39 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-08-15  3:39 UTC (permalink / raw)
  To: Wu Bo; +Cc: io-uring, linfeilong, liuzhiqiang26

On 8/14/20 8:25 PM, Wu Bo wrote:
> NULL check before kfree() is not needed

While it's not needed, it's also slower. Particularly on AMD it seems.
It's on my list to ensure that kfree() is an inline that checks for
non-NULL before calling the real freeing function.

Should get around to that soon, as this is probably the third time
someone has sent this patch :-)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-16  3:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-15  3:25 [PATCH] io_uring: NULL check before kfree() is not needed Wu Bo
2020-08-15  3:39 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox