DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver
@ 2020-06-09  8:44 Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 1/4] net/hns3: fix passing negative parameter to strerror Wei Hu (Xavier)
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Wei Hu (Xavier) @ 2020-06-09  8:44 UTC (permalink / raw)
  To: dev; +Cc: xavier.huwei, ferruh.yigit

This series are bugfixes of coverity defects warning for hns3 PMD driver.

Hongbo Zheng (2):
  net/hns3: avoid unchecked return value in reset err process
  net/hns3: fix unintended sign extension in dump operation

Wei Hu (Xavier) (2):
  net/hns3: fix passing negative parameter to strerror
  net/hns3: fix unintended sign extension in fd operation

 drivers/net/hns3/hns3_fdir.c | 6 +++---
 drivers/net/hns3/hns3_intr.c | 8 +++++++-
 drivers/net/hns3/hns3_regs.c | 2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

-- 
2.7.4


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

* [dpdk-dev] [PATCH 1/4] net/hns3: fix passing negative parameter to strerror
  2020-06-09  8:44 [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Wei Hu (Xavier)
@ 2020-06-09  8:44 ` Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 2/4] net/hns3: avoid unchecked return value in reset err process Wei Hu (Xavier)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Wei Hu (Xavier) @ 2020-06-09  8:44 UTC (permalink / raw)
  To: dev; +Cc: xavier.huwei, ferruh.yigit

There is a coverity defect related "Argument cannot be negative".

This patch fixes it by passing '-ret' to the function strerror() when ret
is negative.

Coverity issue: 349933
Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_fdir.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 4c5928f..7bc5bf8 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -893,7 +893,7 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw,
 	if (ret < 0) {
 		rte_spinlock_unlock(&fdir_info->flows_lock);
 		hns3_err(hw, "Hash table full? err:%d(%s)!", ret,
-			 strerror(ret));
+			 strerror(-ret));
 		return ret;
 	}
 
-- 
2.7.4


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

* [dpdk-dev] [PATCH 2/4] net/hns3: avoid unchecked return value in reset err process
  2020-06-09  8:44 [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 1/4] net/hns3: fix passing negative parameter to strerror Wei Hu (Xavier)
@ 2020-06-09  8:44 ` Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 3/4] net/hns3: fix unintended sign extension in fd operation Wei Hu (Xavier)
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Wei Hu (Xavier) @ 2020-06-09  8:44 UTC (permalink / raw)
  To: dev; +Cc: xavier.huwei, ferruh.yigit

From: Hongbo Zheng <zhenghongbo3@huawei.com>

There is a coverity defect related "Unchecked return value".

The internal static hns3_reset_err_handle function is reset error process
of hns3 PMD driver. If failure in reset process, it does not mean that the
network port is completely unavailable. so the command interface between
driver and firmware still needs to be initialized. Regardless of whether
the execution of the function named hns3_cmd_init is successful or not,
the next process after execution must be continued, so there is no need to
check the return value. If hns3_cmd_init fails to execute, there will be
corresponding log information inside hns3_cmd_init.

This patch adds '(void)' Type conversion to avoid coverity warnning.

Coverity issue: 349934
Fixes: 2790c6464725 ("net/hns3: support device reset")
Cc: stable@dpdk.org

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_intr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c
index 9953a1d..46d617c 100644
--- a/drivers/net/hns3/hns3_intr.c
+++ b/drivers/net/hns3/hns3_intr.c
@@ -882,8 +882,14 @@ hns3_reset_err_handle(struct hns3_adapter *hns)
 		return true;
 	}
 
+	/*
+	 * Failure to reset does not mean that the network port is
+	 * completely unavailable, so cmd still needs to be initialized.
+	 * Regardless of whether the execution is successful or not, the
+	 * flow after execution must be continued.
+	 */
 	if (rte_atomic16_read(&hw->reset.disable_cmd))
-		hns3_cmd_init(hw);
+		(void)hns3_cmd_init(hw);
 reset_fail:
 	hw->reset.attempts = 0;
 	hw->reset.stats.fail_cnt++;
-- 
2.7.4


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

* [dpdk-dev] [PATCH 3/4] net/hns3: fix unintended sign extension in fd operation
  2020-06-09  8:44 [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 1/4] net/hns3: fix passing negative parameter to strerror Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 2/4] net/hns3: avoid unchecked return value in reset err process Wei Hu (Xavier)
@ 2020-06-09  8:44 ` Wei Hu (Xavier)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 4/4] net/hns3: fix unintended sign extension in dump operation Wei Hu (Xavier)
  2020-06-10  9:46 ` [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Ferruh Yigit
  4 siblings, 0 replies; 6+ messages in thread
From: Wei Hu (Xavier) @ 2020-06-09  8:44 UTC (permalink / raw)
  To: dev; +Cc: xavier.huwei, ferruh.yigit

Currently, there are coverity defects warning as below:

CID 349937 (#1 of 1): Unintended sign extension (SIGN_EXTENSION)
sign_extension: Suspicious implicit sign extension: port_number with type
uint16_t (16 bits, unsigned) is promoted in port_number << cur_pos to type
int (32 bits, signed), then sign-extended to type unsigned long (64 bits,
unsigned). If port_number << cur_pos is greater than 0x7FFFFFFF, the upper
bits of the result will all be 1.

CID 349893 (#1 of 1): Unintended sign extension (SIGN_EXTENSION)
sign_extension: Suspicious implicit sign extension: vlan_tag with type
uint8_t (8 bits, unsigned) is promoted in vlan_tag << cur_pos to type int
(32 bits, signed), then sign-extended to type unsigned long (64 bits,
unsigned). If vlan_tag << cur_pos is greater than 0x7FFFFFFF, the upper
bits of the result will all be 1.

This patch fixes them by replacing the data type of port_number and
vlan_tag with uint32_t in the inner static function named
hns3_fd_convert_meta_data of hns3 PMD driver.

Coverity issue: 349937, 349893
Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org

Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_fdir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c
index 7bc5bf8..6ab439d 100644
--- a/drivers/net/hns3/hns3_fdir.c
+++ b/drivers/net/hns3/hns3_fdir.c
@@ -619,7 +619,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg,
 				      uint8_t *key_x, uint8_t *key_y)
 {
 	uint16_t meta_data = 0;
-	uint16_t port_number;
+	uint32_t port_number;
 	uint8_t cur_pos = 0;
 	uint8_t tuple_size;
 	uint8_t shift_bits;
@@ -637,7 +637,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg,
 				     rule->key_conf.spec.tunnel_type ? 1 : 0);
 			cur_pos += tuple_size;
 		} else if (i == VLAN_NUMBER) {
-			uint8_t vlan_tag;
+			uint32_t vlan_tag;
 			uint8_t vlan_num;
 			if (rule->key_conf.spec.tunnel_type == 0)
 				vlan_num = rule->key_conf.vlan_num;
-- 
2.7.4


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

* [dpdk-dev] [PATCH 4/4] net/hns3: fix unintended sign extension in dump operation
  2020-06-09  8:44 [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Wei Hu (Xavier)
                   ` (2 preceding siblings ...)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 3/4] net/hns3: fix unintended sign extension in fd operation Wei Hu (Xavier)
@ 2020-06-09  8:44 ` Wei Hu (Xavier)
  2020-06-10  9:46 ` [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Ferruh Yigit
  4 siblings, 0 replies; 6+ messages in thread
From: Wei Hu (Xavier) @ 2020-06-09  8:44 UTC (permalink / raw)
  To: dev; +Cc: xavier.huwei, ferruh.yigit

From: Hongbo Zheng <zhenghongbo3@huawei.com>

There are coverity defects related "Unintended sign extension" in the
internal static function named hns3_get_regs_length used for dumping reg
operation.

This patch fixes them by replacing the data type of cmdq_lines,
common_lines, ring_lines and tqp_intr_lines with uint32_t in the inner
static function named hns3_get_regs_length of hns3 PMD driver.

Coverity issue: 349917, 349914
Fixes: 936eda25e8da ("net/hns3: support dump register")
Cc: stable@dpdk.org

Signed-off-by: Hongbo Zheng <zhenghongbo3@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index a3f2a51..63c8602 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -116,7 +116,7 @@ static int
 hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length)
 {
 	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
-	int cmdq_lines, common_lines, ring_lines, tqp_intr_lines;
+	uint32_t cmdq_lines, common_lines, ring_lines, tqp_intr_lines;
 	uint32_t regs_num_32_bit, regs_num_64_bit;
 	uint32_t len;
 	int ret;
-- 
2.7.4


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

* Re: [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver
  2020-06-09  8:44 [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Wei Hu (Xavier)
                   ` (3 preceding siblings ...)
  2020-06-09  8:44 ` [dpdk-dev] [PATCH 4/4] net/hns3: fix unintended sign extension in dump operation Wei Hu (Xavier)
@ 2020-06-10  9:46 ` Ferruh Yigit
  4 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2020-06-10  9:46 UTC (permalink / raw)
  To: Wei Hu (Xavier), dev

On 6/9/2020 9:44 AM, Wei Hu (Xavier) wrote:
> This series are bugfixes of coverity defects warning for hns3 PMD driver.
> 
> Hongbo Zheng (2):
>   net/hns3: avoid unchecked return value in reset err process
>   net/hns3: fix unintended sign extension in dump operation
> 
> Wei Hu (Xavier) (2):
>   net/hns3: fix passing negative parameter to strerror
>   net/hns3: fix unintended sign extension in fd operation
> 

Series applied to dpdk-next-net/master, thanks.

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

end of thread, other threads:[~2020-06-10  9:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-09  8:44 [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Wei Hu (Xavier)
2020-06-09  8:44 ` [dpdk-dev] [PATCH 1/4] net/hns3: fix passing negative parameter to strerror Wei Hu (Xavier)
2020-06-09  8:44 ` [dpdk-dev] [PATCH 2/4] net/hns3: avoid unchecked return value in reset err process Wei Hu (Xavier)
2020-06-09  8:44 ` [dpdk-dev] [PATCH 3/4] net/hns3: fix unintended sign extension in fd operation Wei Hu (Xavier)
2020-06-09  8:44 ` [dpdk-dev] [PATCH 4/4] net/hns3: fix unintended sign extension in dump operation Wei Hu (Xavier)
2020-06-10  9:46 ` [dpdk-dev] [PATCH 0/4] Bugfixes of coverity defects for hns3 PMD driver Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).