patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close
@ 2020-08-26 11:54 wangyunjian
  2020-08-26 12:08 ` Sachin Saxena (OSS)
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: wangyunjian @ 2020-08-26 11:54 UTC (permalink / raw)
  To: dev, hemant.agrawal, sachin.saxena
  Cc: jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The fd is possibly a negative value while it is passed as an
argument to function "close". Fix the check to the fd.

Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index 1166d68e2..1bff0bc2f 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -142,7 +142,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 	struct qm_portal_config *q_pcfg;
 	struct dpaa_ioctl_irq_map irq_map;
 	struct dpaa_ioctl_portal_map q_map = {0};
-	int q_fd = 0, ret;
+	int q_fd = -1, ret;
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
@@ -191,7 +191,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 err:
 	if (portal)
 		qman_free_global_portal(portal);
-	if (q_fd)
+	if (q_fd != -1)
 		close(q_fd);
 	process_portal_unmap(&q_map.addr);
 	kfree(q_pcfg);
-- 
2.23.0



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close
  2020-08-26 11:54 [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close wangyunjian
@ 2020-08-26 12:08 ` Sachin Saxena (OSS)
  2020-09-14 17:24 ` Ferruh Yigit
  2020-09-15 11:57 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
  2 siblings, 0 replies; 7+ messages in thread
From: Sachin Saxena (OSS) @ 2020-08-26 12:08 UTC (permalink / raw)
  To: wangyunjian, dev, hemant.agrawal, sachin.saxena
  Cc: jerry.lilijun, xudingke, stable

Thanks Yunjian for the fix.

Acked-by: Sachin Saxena<sachin.saxena@oss.nxp.com>


On 26-Aug-20 5:24 PM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> The fd is possibly a negative value while it is passed as an
> argument to function "close". Fix the check to the fd.
>
> Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
> index 1166d68e2..1bff0bc2f 100644
> --- a/drivers/bus/dpaa/base/qbman/qman_driver.c
> +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
> @@ -142,7 +142,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
>   	struct qm_portal_config *q_pcfg;
>   	struct dpaa_ioctl_irq_map irq_map;
>   	struct dpaa_ioctl_portal_map q_map = {0};
> -	int q_fd = 0, ret;
> +	int q_fd = -1, ret;
>   
>   	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
>   	if (!q_pcfg) {
> @@ -191,7 +191,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
>   err:
>   	if (portal)
>   		qman_free_global_portal(portal);
> -	if (q_fd)
> +	if (q_fd != -1)
>   		close(q_fd);
>   	process_portal_unmap(&q_map.addr);
>   	kfree(q_pcfg);


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close
  2020-08-26 11:54 [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close wangyunjian
  2020-08-26 12:08 ` Sachin Saxena (OSS)
@ 2020-09-14 17:24 ` Ferruh Yigit
  2020-09-15 12:03   ` wangyunjian
  2020-09-15 11:57 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
  2 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2020-09-14 17:24 UTC (permalink / raw)
  To: wangyunjian, dev, hemant.agrawal, sachin.saxena
  Cc: jerry.lilijun, xudingke, stable

On 8/26/2020 12:54 PM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The fd is possibly a negative value while it is passed as an
> argument to function "close". Fix the check to the fd.
> 
> Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>  drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
> index 1166d68e2..1bff0bc2f 100644
> --- a/drivers/bus/dpaa/base/qbman/qman_driver.c
> +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
> @@ -142,7 +142,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
>  	struct qm_portal_config *q_pcfg;
>  	struct dpaa_ioctl_irq_map irq_map;
>  	struct dpaa_ioctl_portal_map q_map = {0};
> -	int q_fd = 0, ret;
> +	int q_fd = -1, ret;
>  
>  	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
>  	if (!q_pcfg) {
> @@ -191,7 +191,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
>  err:
>  	if (portal)
>  		qman_free_global_portal(portal);
> -	if (q_fd)
> +	if (q_fd != -1)
>  		close(q_fd);

There is already a 'if (q_fd == -1)' check above to goto this label,
what do you think adding a second label to remove duplicated check?

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

* [dpdk-stable] [dpdk-dev] [PATCH v2] bus/dpaa: fix fd check before close
  2020-08-26 11:54 [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close wangyunjian
  2020-08-26 12:08 ` Sachin Saxena (OSS)
  2020-09-14 17:24 ` Ferruh Yigit
@ 2020-09-15 11:57 ` " wangyunjian
  2020-09-16 14:48   ` Hemant Agrawal
  2020-09-16 23:05   ` Ferruh Yigit
  2 siblings, 2 replies; 7+ messages in thread
From: wangyunjian @ 2020-09-15 11:57 UTC (permalink / raw)
  To: dev
  Cc: hemant.agrawal, sachin.saxena, ferruh.yigit, jerry.lilijun,
	xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The fd is possibly a negative value while it is passed as an
argument to function "close". Fix the check to the fd.

Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
v2:
   Remove duplicated check suggested by Ferruh Yigit
---
 drivers/bus/dpaa/base/qbman/qman_driver.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c
index a466c698f..6d9aaff16 100644
--- a/drivers/bus/dpaa/base/qbman/qman_driver.c
+++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
@@ -142,7 +142,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 	struct qm_portal_config *q_pcfg;
 	struct dpaa_ioctl_irq_map irq_map;
 	struct dpaa_ioctl_portal_map q_map = {0};
-	int q_fd = 0, ret;
+	int q_fd, ret;
 
 	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
 	if (!q_pcfg) {
@@ -179,7 +179,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 	if (!portal) {
 		pr_err("Qman portal initialisation failed (%d)\n",
 		       q_pcfg->cpu);
-		goto err;
+		goto err_alloc;
 	}
 
 	irq_map.type = dpaa_portal_qman;
@@ -188,9 +188,9 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd)
 
 	*fd = q_fd;
 	return portal;
+err_alloc:
+	close(q_fd);
 err:
-	if (q_fd)
-		close(q_fd);
 	process_portal_unmap(&q_map.addr);
 	kfree(q_pcfg);
 	return NULL;
-- 
2.23.0


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close
  2020-09-14 17:24 ` Ferruh Yigit
@ 2020-09-15 12:03   ` wangyunjian
  0 siblings, 0 replies; 7+ messages in thread
From: wangyunjian @ 2020-09-15 12:03 UTC (permalink / raw)
  To: Ferruh Yigit, dev, hemant.agrawal, sachin.saxena
  Cc: Lilijun (Jerry), xudingke, stable



> -----Original Message-----
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Tuesday, September 15, 2020 1:24 AM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org;
> hemant.agrawal@nxp.com; sachin.saxena@nxp.com
> Cc: Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; stable@dpdk.org
> Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before
> close
> 
> On 8/26/2020 12:54 PM, wangyunjian wrote:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The fd is possibly a negative value while it is passed as an argument
> > to function "close". Fix the check to the fd.
> >
> > Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >  drivers/bus/dpaa/base/qbman/qman_driver.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c
> > b/drivers/bus/dpaa/base/qbman/qman_driver.c
> > index 1166d68e2..1bff0bc2f 100644
> > --- a/drivers/bus/dpaa/base/qbman/qman_driver.c
> > +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c
> > @@ -142,7 +142,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int
> *fd)
> >  	struct qm_portal_config *q_pcfg;
> >  	struct dpaa_ioctl_irq_map irq_map;
> >  	struct dpaa_ioctl_portal_map q_map = {0};
> > -	int q_fd = 0, ret;
> > +	int q_fd = -1, ret;
> >
> >  	q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0);
> >  	if (!q_pcfg) {
> > @@ -191,7 +191,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int
> > *fd)
> >  err:
> >  	if (portal)
> >  		qman_free_global_portal(portal);
> > -	if (q_fd)
> > +	if (q_fd != -1)
> >  		close(q_fd);
> 
> There is already a 'if (q_fd == -1)' check above to goto this label, what do you
> think adding a second label to remove duplicated check?

Thanks for your suggestion. I will do like this.

Yunjian

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] bus/dpaa: fix fd check before close
  2020-09-15 11:57 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
@ 2020-09-16 14:48   ` Hemant Agrawal
  2020-09-16 23:05   ` Ferruh Yigit
  1 sibling, 0 replies; 7+ messages in thread
From: Hemant Agrawal @ 2020-09-16 14:48 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: hemant.agrawal, sachin.saxena, ferruh.yigit, jerry.lilijun,
	xudingke, stable

Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] bus/dpaa: fix fd check before close
  2020-09-15 11:57 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
  2020-09-16 14:48   ` Hemant Agrawal
@ 2020-09-16 23:05   ` Ferruh Yigit
  1 sibling, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2020-09-16 23:05 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: hemant.agrawal, sachin.saxena, jerry.lilijun, xudingke, stable

On 9/15/2020 12:57 PM, wangyunjian wrote:
>> From: Yunjian Wang <wangyunjian@huawei.com>
>> 
>> The fd is possibly a negative value while it is passed as an
>> argument to function "close". Fix the check to the fd.
>> 
>> Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init")
>> Cc: stable@dpdk.org
>> 
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>
 > Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
 >

Applied to dpdk-next-net/main, thanks.

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 11:54 [dpdk-stable] [dpdk-dev] [PATCH] bus/dpaa: fix fd check before close wangyunjian
2020-08-26 12:08 ` Sachin Saxena (OSS)
2020-09-14 17:24 ` Ferruh Yigit
2020-09-15 12:03   ` wangyunjian
2020-09-15 11:57 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
2020-09-16 14:48   ` Hemant Agrawal
2020-09-16 23:05   ` Ferruh Yigit

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://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/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


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