diff mbox series

io_uring: Remove redundant NULL check before kfree

Message ID 20220602071841.278214-1-chi.minghao@zte.com.cn (mailing list archive)
State New
Headers show
Series io_uring: Remove redundant NULL check before kfree | expand

Commit Message

CGEL June 2, 2022, 7:18 a.m. UTC
From: Minghao Chi <chi.minghao@zte.com.cn>

kfree on NULL pointer is a no-op.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
 fs/io_uring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jens Axboe June 2, 2022, 7:47 a.m. UTC | #1
On 6/2/22 1:18 AM, cgel.zte@gmail.com wrote:
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 1fc0166d9133..d1fe967f2343 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -4445,8 +4445,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
>  	kiocb_done(req, ret, issue_flags);
>  out_free:
>  	/* it's faster to check here then delegate to kfree */
> -	if (iovec)
> -		kfree(iovec);
> +	kfree(iovec);
>  	return 0;
>  }

There is _literally_ a comment right above your change that explains why
this is there. Please read surrounding code, at least.
diff mbox series

Patch

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 1fc0166d9133..d1fe967f2343 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4445,8 +4445,7 @@  static int io_read(struct io_kiocb *req, unsigned int issue_flags)
 	kiocb_done(req, ret, issue_flags);
 out_free:
 	/* it's faster to check here then delegate to kfree */
-	if (iovec)
-		kfree(iovec);
+	kfree(iovec);
 	return 0;
 }