* [PATCH -next] io_uring: Remove unneeded if-null-free check
@ 2021-06-02 6:54 Zheng Yongjun
2021-06-15 13:37 ` Pavel Begunkov
0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yongjun @ 2021-06-02 6:54 UTC (permalink / raw)
To: axboe, io-uring, linux-kernel; +Cc: asml.silence, Zheng Yongjun
Eliminate the following coccicheck warning:
fs/io_uring.c:6056:4-9: WARNING: NULL check before some freeing functions is not needed.
fs/io_uring.c:1744:2-7: WARNING: NULL check before some freeing functions is not needed.
fs/io_uring.c:3340:2-7: WARNING: NULL check before some freeing functions is not needed.
fs/io_uring.c:4612:2-7: WARNING: NULL check before some freeing functions is not needed.
fs/io_uring.c:4375:2-7: WARNING: NULL check before some freeing functions is not needed.
fs/io_uring.c:3441:2-7: WARNING: NULL check before some freeing functions is not needed.
Signed-off-by: Zheng Yongjun <[email protected]>
---
fs/io_uring.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 5f82954004f6..6d0b3d09d92d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1740,8 +1740,7 @@ static void io_dismantle_req(struct io_kiocb *req)
io_put_file(req->file);
if (req->fixed_rsrc_refs)
percpu_ref_put(req->fixed_rsrc_refs);
- if (req->async_data)
- kfree(req->async_data);
+ kfree(req->async_data);
if (req->work.creds) {
put_cred(req->work.creds);
req->work.creds = NULL;
@@ -3336,8 +3335,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
kiocb_done(kiocb, ret, issue_flags);
out_free:
/* it's faster to check here then delegate to kfree */
- if (iovec)
- kfree(iovec);
+ kfree(iovec);
return 0;
}
@@ -3437,8 +3435,7 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
}
out_free:
/* it's reportedly faster than delegating the null check to kfree() */
- if (iovec)
- kfree(iovec);
+ kfree(iovec);
return ret;
}
@@ -4371,8 +4368,7 @@ static int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
ret = -EINTR;
/* fast path, check for non-NULL to avoid function call */
- if (kmsg->free_iov)
- kfree(kmsg->free_iov);
+ kfree(kmsg->free_iov);
req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret < min_ret)
req_set_fail_links(req);
@@ -4608,8 +4604,7 @@ static int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
if (req->flags & REQ_F_BUFFER_SELECTED)
cflags = io_put_recv_kbuf(req);
/* fast path, check for non-NULL to avoid function call */
- if (kmsg->free_iov)
- kfree(kmsg->free_iov);
+ kfree(kmsg->free_iov);
req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret < min_ret || ((flags & MSG_WAITALL) && (kmsg->msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))))
req_set_fail_links(req);
@@ -6052,8 +6047,7 @@ static void io_clean_op(struct io_kiocb *req)
case IORING_OP_WRITE_FIXED:
case IORING_OP_WRITE: {
struct io_async_rw *io = req->async_data;
- if (io->free_iovec)
- kfree(io->free_iovec);
+ kfree(io->free_iovec);
break;
}
case IORING_OP_RECVMSG:
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] io_uring: Remove unneeded if-null-free check
2021-06-02 6:54 [PATCH -next] io_uring: Remove unneeded if-null-free check Zheng Yongjun
@ 2021-06-15 13:37 ` Pavel Begunkov
0 siblings, 0 replies; 2+ messages in thread
From: Pavel Begunkov @ 2021-06-15 13:37 UTC (permalink / raw)
To: Zheng Yongjun, axboe, io-uring, linux-kernel
On 6/2/21 7:54 AM, Zheng Yongjun wrote:
> Eliminate the following coccicheck warning:
>
> fs/io_uring.c:6056:4-9: WARNING: NULL check before some freeing functions is not needed.
> fs/io_uring.c:1744:2-7: WARNING: NULL check before some freeing functions is not needed.
> fs/io_uring.c:3340:2-7: WARNING: NULL check before some freeing functions is not needed.
> fs/io_uring.c:4612:2-7: WARNING: NULL check before some freeing functions is not needed.
> fs/io_uring.c:4375:2-7: WARNING: NULL check before some freeing functions is not needed.
> fs/io_uring.c:3441:2-7: WARNING: NULL check before some freeing functions is not needed.
Take a look at the comments right above changed lines.
>
> Signed-off-by: Zheng Yongjun <[email protected]>
> ---
> fs/io_uring.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
[...]
> /* it's reportedly faster than delegating the null check to kfree() */
> - if (iovec)
> - kfree(iovec);
> + kfree(iovec);
[...]
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-15 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-02 6:54 [PATCH -next] io_uring: Remove unneeded if-null-free check Zheng Yongjun
2021-06-15 13:37 ` Pavel Begunkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox