public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: Remove redundant NULL check before kfree
@ 2022-06-02  7:18 cgel.zte
  2022-06-02  7:47 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-06-02  7:18 UTC (permalink / raw)
  To: axboe; +Cc: asml.silence, io-uring, linux-kernel, Minghao Chi, Zeal Robot

From: Minghao Chi <[email protected]>

kfree on NULL pointer is a no-op.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Minghao Chi <[email protected]>
---
 fs/io_uring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

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;
 }
 
-- 
2.25.1




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

* Re: [PATCH] io_uring: Remove redundant NULL check before kfree
  2022-06-02  7:18 [PATCH] io_uring: Remove redundant NULL check before kfree cgel.zte
@ 2022-06-02  7:47 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-06-02  7:47 UTC (permalink / raw)
  To: cgel.zte; +Cc: asml.silence, io-uring, linux-kernel, Minghao Chi, Zeal Robot

On 6/2/22 1:18 AM, [email protected] 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.

-- 
Jens Axboe



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

end of thread, other threads:[~2022-06-02  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-02  7:18 [PATCH] io_uring: Remove redundant NULL check before kfree cgel.zte
2022-06-02  7:47 ` Jens Axboe

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