[dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd

Gagandeep Singh G.Singh at nxp.com
Sat May 9 19:44:09 CEST 2020



> -----Original Message-----
> From: wangyunjian <wangyunjian at huawei.com>
> Sent: Sunday, April 26, 2020 6:31 PM
> To: dev at dpdk.org
> Cc: Gagandeep Singh <G.Singh at nxp.com>; Hemant Agrawal
> <hemant.agrawal at nxp.com>; jerry.lilijun at huawei.com;
> xudingke at huawei.com; Yunjian Wang <wangyunjian at huawei.com>;
> stable at dpdk.org
> Subject: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> 
> From: Yunjian Wang <wangyunjian at huawei.com>
> 
> Zero is a valid fd. It will fail to check the fd if the fd is zero.
> 
> Fixes: e7a45f3cc245 ("crypto/caam_jr: add UIO specific operations")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
> ---
>  drivers/crypto/caam_jr/caam_jr_uio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/caam_jr/caam_jr_uio.c
> b/drivers/crypto/caam_jr/caam_jr_uio.c
> index b1bb44ca4..658de5460 100644
> --- a/drivers/crypto/caam_jr/caam_jr_uio.c
> +++ b/drivers/crypto/caam_jr/caam_jr_uio.c
> @@ -145,7 +145,7 @@ file_read_first_line(const char root[], const char
> subdir[],
>  		 "%s/%s/%s", root, subdir, filename);
> 
>  	fd = open(absolute_file_name, O_RDONLY);
> -	SEC_ASSERT(fd > 0, fd, "Error opening file %s",
> +	SEC_ASSERT(fd >= 0, fd, "Error opening file %s",
>  			absolute_file_name);
> 
>  	/* read UIO device name from first line in file */
> @@ -389,7 +389,7 @@ uio_job_ring *config_job_ring(void)
> 
>  	/* Open device file */
>  	job_ring->uio_fd = open(uio_device_file_name, O_RDWR);
> -	SEC_ASSERT(job_ring->uio_fd > 0, NULL,
> +	SEC_ASSERT(job_ring->uio_fd >= 0, NULL,
>  		"Failed to open UIO device file for job ring %d",
>  		job_ring->jr_id);
> 
> @@ -488,7 +488,7 @@ sec_cleanup(void)
>  		/* I need to close the fd after shutdown UIO commands need to
> be
>  		 * sent using the fd
>  		 */
> -		if (job_ring->uio_fd != 0) {
> +		if (job_ring->uio_fd >= 0) {
>  			CAAM_JR_INFO(
>  			"Closed device file for job ring %d , fd = %d",
>  			job_ring->jr_id, job_ring->uio_fd);
> --
> 2.19.1
> 


Reviewed-by: Gagandeep Singh <G.singh at nxp.com>




More information about the dev mailing list