DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan
@ 2020-11-05  2:05 Wei Huang
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail Wei Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wei Huang @ 2020-11-05  2:05 UTC (permalink / raw)
  To: dev, rosen.xu, qi.z.zhang; +Cc: stable, Wei Huang

Two issues are introduced from previous patch, one resides in 
ifpga_fme.c and the other resides in opae_hw_api.c. Below two
patches are provided to fix them separately.

Main changes from v2:
- Fix coding style issue

Wei Huang (2):
  raw/ifpga/base: unlock mutex when nios init fail
  raw/ifpga/base: check pointer adapter before dereference

 drivers/raw/ifpga/base/ifpga_fme.c   |  2 ++
 drivers/raw/ifpga/base/opae_hw_api.c | 10 ++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.29.2


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

* [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail
  2020-11-05  2:05 [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Wei Huang
@ 2020-11-05  2:05 ` Wei Huang
  2020-11-05 11:32   ` Xu, Rosen
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before dereference Wei Huang
  2020-11-09  9:41 ` [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Zhang, Qi Z
  2 siblings, 1 reply; 6+ messages in thread
From: Wei Huang @ 2020-11-05  2:05 UTC (permalink / raw)
  To: dev, rosen.xu, qi.z.zhang; +Cc: stable, Wei Huang

In fme_nios_spi_init(), a mutex is locked for protecting nios
initialization process, the mutex is only unlocked when process
is successful, it should also be unlocked when process fail.

Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process")
Coverity issue: 363751

Signed-off-by: Wei Huang <wei.huang@intel.com>
---
 drivers/raw/ifpga/base/ifpga_fme.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/raw/ifpga/base/ifpga_fme.c b/drivers/raw/ifpga/base/ifpga_fme.c
index 540bb1110..f29ff3159 100644
--- a/drivers/raw/ifpga/base/ifpga_fme.c
+++ b/drivers/raw/ifpga/base/ifpga_fme.c
@@ -1115,6 +1115,8 @@ static int fme_nios_spi_init(struct ifpga_feature *feature)
 	ret = nios_spi_wait_init_done(spi_master);
 	if (ret != 0) {
 		dev_err(fme, "FME NIOS_SPI init fail\n");
+		if (spi_master->mutex)
+			pthread_mutex_unlock(spi_master->mutex);
 		goto release_dev;
 	}
 
-- 
2.29.2


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

* [dpdk-dev] [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before dereference
  2020-11-05  2:05 [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Wei Huang
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail Wei Huang
@ 2020-11-05  2:05 ` Wei Huang
  2020-11-05 11:32   ` Xu, Rosen
  2020-11-09  9:41 ` [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Zhang, Qi Z
  2 siblings, 1 reply; 6+ messages in thread
From: Wei Huang @ 2020-11-05  2:05 UTC (permalink / raw)
  To: dev, rosen.xu, qi.z.zhang; +Cc: stable, Wei Huang

In opae_adapter_destroy(), pointer "adapter" is not validated before
passing it to opae_adapter_shm_free() and opae_adapter_mutex_close()
which dereference it.

Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process")
Coverity issue: 363752

Signed-off-by: Wei Huang <wei.huang@intel.com>
---
v2: fix typo in commit log
---
 drivers/raw/ifpga/base/opae_hw_api.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/raw/ifpga/base/opae_hw_api.c b/drivers/raw/ifpga/base/opae_hw_api.c
index 600afdea1..d5cd5fe60 100644
--- a/drivers/raw/ifpga/base/opae_hw_api.c
+++ b/drivers/raw/ifpga/base/opae_hw_api.c
@@ -605,10 +605,12 @@ int opae_adapter_enumerate(struct opae_adapter *adapter)
  */
 void opae_adapter_destroy(struct opae_adapter *adapter)
 {
-	if (adapter && adapter->ops && adapter->ops->destroy)
-		adapter->ops->destroy(adapter);
-	opae_adapter_shm_free(adapter);
-	opae_adapter_mutex_close(adapter);
+	if (adapter) {
+		if (adapter->ops && adapter->ops->destroy)
+			adapter->ops->destroy(adapter);
+		opae_adapter_shm_free(adapter);
+		opae_adapter_mutex_close(adapter);
+	}
 }
 
 /**
-- 
2.29.2


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

* Re: [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail Wei Huang
@ 2020-11-05 11:32   ` Xu, Rosen
  0 siblings, 0 replies; 6+ messages in thread
From: Xu, Rosen @ 2020-11-05 11:32 UTC (permalink / raw)
  To: Huang, Wei, dev, Zhang, Qi Z; +Cc: stable

Hi,

> -----Original Message-----
> From: Huang, Wei <wei.huang@intel.com>
> Sent: Thursday, November 05, 2020 10:06
> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: stable@dpdk.org; Huang, Wei <wei.huang@intel.com>
> Subject: [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail
> 
> In fme_nios_spi_init(), a mutex is locked for protecting nios initialization
> process, the mutex is only unlocked when process is successful, it should also
> be unlocked when process fail.
> 
> Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-
> process") Coverity issue: 363751
> 
> Signed-off-by: Wei Huang <wei.huang@intel.com>
> ---
>  drivers/raw/ifpga/base/ifpga_fme.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/raw/ifpga/base/ifpga_fme.c
> b/drivers/raw/ifpga/base/ifpga_fme.c
> index 540bb1110..f29ff3159 100644
> --- a/drivers/raw/ifpga/base/ifpga_fme.c
> +++ b/drivers/raw/ifpga/base/ifpga_fme.c
> @@ -1115,6 +1115,8 @@ static int fme_nios_spi_init(struct ifpga_feature
> *feature)
>  	ret = nios_spi_wait_init_done(spi_master);
>  	if (ret != 0) {
>  		dev_err(fme, "FME NIOS_SPI init fail\n");
> +		if (spi_master->mutex)
> +			pthread_mutex_unlock(spi_master->mutex);
>  		goto release_dev;
>  	}
> 
> --
> 2.29.2

Acked-by: Rosen Xu <rosen.xu@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before dereference
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before dereference Wei Huang
@ 2020-11-05 11:32   ` Xu, Rosen
  0 siblings, 0 replies; 6+ messages in thread
From: Xu, Rosen @ 2020-11-05 11:32 UTC (permalink / raw)
  To: Huang, Wei, dev, Zhang, Qi Z; +Cc: stable

Hi,

> -----Original Message-----
> From: Huang, Wei <wei.huang@intel.com>
> Sent: Thursday, November 05, 2020 10:06
> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: stable@dpdk.org; Huang, Wei <wei.huang@intel.com>
> Subject: [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before
> dereference
> 
> In opae_adapter_destroy(), pointer "adapter" is not validated before passing
> it to opae_adapter_shm_free() and opae_adapter_mutex_close() which
> dereference it.
> 
> Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-
> process") Coverity issue: 363752
> 
> Signed-off-by: Wei Huang <wei.huang@intel.com>
> ---
> v2: fix typo in commit log
> ---
>  drivers/raw/ifpga/base/opae_hw_api.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/raw/ifpga/base/opae_hw_api.c
> b/drivers/raw/ifpga/base/opae_hw_api.c
> index 600afdea1..d5cd5fe60 100644
> --- a/drivers/raw/ifpga/base/opae_hw_api.c
> +++ b/drivers/raw/ifpga/base/opae_hw_api.c
> @@ -605,10 +605,12 @@ int opae_adapter_enumerate(struct opae_adapter
> *adapter)
>   */
>  void opae_adapter_destroy(struct opae_adapter *adapter)  {
> -	if (adapter && adapter->ops && adapter->ops->destroy)
> -		adapter->ops->destroy(adapter);
> -	opae_adapter_shm_free(adapter);
> -	opae_adapter_mutex_close(adapter);
> +	if (adapter) {
> +		if (adapter->ops && adapter->ops->destroy)
> +			adapter->ops->destroy(adapter);
> +		opae_adapter_shm_free(adapter);
> +		opae_adapter_mutex_close(adapter);
> +	}
>  }
> 
>  /**
> --
> 2.29.2

Acked-by: Rosen Xu <rosen.xu@intel.com>

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

* Re: [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan
  2020-11-05  2:05 [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Wei Huang
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail Wei Huang
  2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before dereference Wei Huang
@ 2020-11-09  9:41 ` Zhang, Qi Z
  2 siblings, 0 replies; 6+ messages in thread
From: Zhang, Qi Z @ 2020-11-09  9:41 UTC (permalink / raw)
  To: Huang, Wei, dev, Xu, Rosen; +Cc: stable



> -----Original Message-----
> From: Huang, Wei <wei.huang@intel.com>
> Sent: Thursday, November 5, 2020 10:06 AM
> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: stable@dpdk.org; Huang, Wei <wei.huang@intel.com>
> Subject: [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan
> 
> Two issues are introduced from previous patch, one resides in ifpga_fme.c and
> the other resides in opae_hw_api.c. Below two patches are provided to fix
> them separately.
> 
> Main changes from v2:
> - Fix coding style issue
> 
> Wei Huang (2):
>   raw/ifpga/base: unlock mutex when nios init fail
>   raw/ifpga/base: check pointer adapter before dereference
> 
>  drivers/raw/ifpga/base/ifpga_fme.c   |  2 ++
>  drivers/raw/ifpga/base/opae_hw_api.c | 10 ++++++----
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> --
> 2.29.2

Applied to dpdk-next-net-intel.

Thanks
Qi

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

end of thread, other threads:[~2020-11-09  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05  2:05 [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Wei Huang
2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 1/2] raw/ifpga/base: unlock mutex when nios init fail Wei Huang
2020-11-05 11:32   ` Xu, Rosen
2020-11-05  2:05 ` [dpdk-dev] [PATCH v2 2/2] raw/ifpga/base: check pointer adapter before dereference Wei Huang
2020-11-05 11:32   ` Xu, Rosen
2020-11-09  9:41 ` [dpdk-dev] [PATCH v2 0/2] raw/ifpga/base: fix defects found by coverity scan Zhang, Qi Z

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/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 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

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


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