patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
@ 2020-04-26 13:00 wangyunjian
  2020-05-09 17:44 ` Gagandeep Singh
  0 siblings, 1 reply; 4+ messages in thread
From: wangyunjian @ 2020-04-26 13:00 UTC (permalink / raw)
  To: dev
  Cc: g.singh, hemant.agrawal, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@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@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@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



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
  2020-04-26 13:00 [dpdk-stable] [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd wangyunjian
@ 2020-05-09 17:44 ` Gagandeep Singh
  2020-05-10  5:53   ` Gagandeep Singh
  0 siblings, 1 reply; 4+ messages in thread
From: Gagandeep Singh @ 2020-05-09 17:44 UTC (permalink / raw)
  To: wangyunjian, dev, Akhil Goyal
  Cc: Hemant Agrawal, jerry.lilijun, xudingke, stable



> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Sunday, April 26, 2020 6:31 PM
> To: dev@dpdk.org
> Cc: Gagandeep Singh <G.Singh@nxp.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; jerry.lilijun@huawei.com;
> xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> 
> From: Yunjian Wang <wangyunjian@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@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@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@nxp.com>



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
  2020-05-09 17:44 ` Gagandeep Singh
@ 2020-05-10  5:53   ` Gagandeep Singh
  2020-05-11  2:13     ` wangyunjian
  0 siblings, 1 reply; 4+ messages in thread
From: Gagandeep Singh @ 2020-05-10  5:53 UTC (permalink / raw)
  To: wangyunjian, dev, Akhil Goyal
  Cc: Hemant Agrawal, jerry.lilijun, xudingke, stable

Hi Yunjian,

> -----Original Message-----
> From: Gagandeep Singh
> Sent: Saturday, May 9, 2020 11:14 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org; Akhil Goyal
> <akhil.goyal@nxp.com>
> Cc: Hemant Agrawal <hemant.agrawal@nxp.com>; jerry.lilijun@huawei.com;
> xudingke@huawei.com; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> 
> 
> 
> > -----Original Message-----
> > From: wangyunjian <wangyunjian@huawei.com>
> > Sent: Sunday, April 26, 2020 6:31 PM
> > To: dev@dpdk.org
> > Cc: Gagandeep Singh <G.Singh@nxp.com>; Hemant Agrawal
> > <hemant.agrawal@nxp.com>; jerry.lilijun@huawei.com;
> > xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>;
> > stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> >
> > From: Yunjian Wang <wangyunjian@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@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@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@nxp.com>
> 

"job_ring->uio_fd" is currently defined as uint32_t, so your patch will create the compilation issue. Please change it to int.


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
  2020-05-10  5:53   ` Gagandeep Singh
@ 2020-05-11  2:13     ` wangyunjian
  0 siblings, 0 replies; 4+ messages in thread
From: wangyunjian @ 2020-05-11  2:13 UTC (permalink / raw)
  To: Gagandeep Singh, dev, Akhil Goyal
  Cc: Hemant Agrawal, Lilijun (Jerry), xudingke, stable

> -----Original Message-----
> From: Gagandeep Singh [mailto:G.Singh@nxp.com]
> Sent: Sunday, May 10, 2020 1:54 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org; Akhil Goyal
> <akhil.goyal@nxp.com>
> Cc: Hemant Agrawal <hemant.agrawal@nxp.com>; Lilijun (Jerry)
> <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>;
> stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> 
> Hi Yunjian,
> 
> > -----Original Message-----
> > From: Gagandeep Singh
> > Sent: Saturday, May 9, 2020 11:14 PM
> > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org; Akhil Goyal
> > <akhil.goyal@nxp.com>
> > Cc: Hemant Agrawal <hemant.agrawal@nxp.com>;
> jerry.lilijun@huawei.com;
> > xudingke@huawei.com; stable@dpdk.org
> > Subject: RE: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> >
> >
> >
> > > -----Original Message-----
> > > From: wangyunjian <wangyunjian@huawei.com>
> > > Sent: Sunday, April 26, 2020 6:31 PM
> > > To: dev@dpdk.org
> > > Cc: Gagandeep Singh <G.Singh@nxp.com>; Hemant Agrawal
> > > <hemant.agrawal@nxp.com>; jerry.lilijun@huawei.com;
> > > xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>;
> > > stable@dpdk.org
> > > Subject: [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd
> > >
> > > From: Yunjian Wang <wangyunjian@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@dpdk.org
> > >
> > > Signed-off-by: Yunjian Wang <wangyunjian@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@nxp.com>
> >
> 
> "job_ring->uio_fd" is currently defined as uint32_t, so your patch will create the
> compilation issue. Please change it to int.

Thanks, I will fix it in next version.

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

end of thread, other threads:[~2020-05-11  2:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 13:00 [dpdk-stable] [dpdk-dev] [PATCH] crypto/caam_jr: fix wrong check of fd wangyunjian
2020-05-09 17:44 ` Gagandeep Singh
2020-05-10  5:53   ` Gagandeep Singh
2020-05-11  2:13     ` wangyunjian

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git