Re: [PATCH] io_uring: Remove unneeded NULL check before free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
thanks for the patch, but as explained in some comments in the code,
it's seems faster to do the check and avoid to call kfree() in the
critical data path.

On Thu, Sep 24, 2020 at 09:36:06AM +0800, Ye Bin wrote:
> Fixes coccicheck warnig:
> fs//io_uring.c:5775:4-9: WARNING: NULL check before some freeing
> functions is not needed.
> fs//io_uring.c:1617:2-7: WARNING: NULL check before some freeing
> functions is not needed.
> fs//io_uring.c:3291:2-7: WARNING: NULL check before some freeing
> functions is not needed.
> fs//io_uring.c:3398:2-7: WARNING: NULL check before some freeing
> functions is not needed.
> 
> Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
> Signed-off-by: Ye Bin <yebin10@xxxxxxxxxx>
> ---
>  fs/io_uring.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 815be15c2aee..23f99ffbb480 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -1613,8 +1613,7 @@ static bool io_dismantle_req(struct io_kiocb *req)
>  {
>  	io_clean_op(req);
>  
> -	if (req->async_data)
> -		kfree(req->async_data);
> +	kfree(req->async_data);
>  	if (req->file)
>  		io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
>  
> @@ -3287,8 +3286,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
>  	ret = 0;
>  out_free:
>  	/* it's reportedly faster than delegating the null check to kfree() */
For example here ^

> -	if (iovec)
> -		kfree(iovec);
> +	kfree(iovec);
>  	return ret;
>  }
>  
> @@ -3394,8 +3392,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
>  	}
>  out_free:
>  	/* it's reportedly faster than delegating the null check to kfree() */
> -	if (iovec)
> -		kfree(iovec);
> +	kfree(iovec);
>  	return ret;
>  }
>  
> @@ -5771,8 +5768,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.16.2.dirty
> 

Thanks,
Stefano




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux