net/hns3: fix out-of-bounds access

Message ID c014c8da5b6d90b6a1658bff231c9ba44abd9e24.1599297849.git.wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/hns3: fix out-of-bounds access |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Yunjian Wang Sept. 7, 2020, 1:46 a.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

This patch fixes (out-of-bounds access) coverity issue.

Coverity issue: 349932
Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Wei Hu (Xavier) Sept. 7, 2020, 2:13 a.m. UTC | #1
On 2020/9/7 9:46, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> This patch fixes (out-of-bounds access) coverity issue.
>
> Coverity issue: 349932
> Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>

> ---
>   drivers/net/hns3/hns3_ethdev.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
> index 81e773046..efe515221 100644
> --- a/drivers/net/hns3/hns3_ethdev.c
> +++ b/drivers/net/hns3/hns3_ethdev.c
> @@ -1401,7 +1401,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
>   	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
>   	struct hns3_mac_vlan_tbl_entry_cmd req;
>   	struct hns3_pf *pf = &hns->pf;
> -	struct hns3_cmd_desc desc;
> +	struct hns3_cmd_desc desc[3];
>   	char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
>   	uint16_t egress_port = 0;
>   	uint8_t vf_id;
> @@ -1435,7 +1435,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
>   	 * it if the entry is inexistent. Repeated unicast entry
>   	 * is not allowed in the mac vlan table.
>   	 */
> -	ret = hns3_lookup_mac_vlan_tbl(hw, &req, &desc, false);
> +	ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, false);
>   	if (ret == -ENOENT) {
>   		if (!hns3_is_umv_space_full(hw)) {
>   			ret = hns3_add_mac_vlan_tbl(hw, &req, NULL);
  
Ferruh Yigit Sept. 8, 2020, 9:43 a.m. UTC | #2
On 9/7/2020 3:13 AM, Wei Hu (Xavier) wrote:
> 
> On 2020/9/7 9:46, wangyunjian wrote:
>> From: Yunjian Wang <wangyunjian@huawei.com>
>>
>> This patch fixes (out-of-bounds access) coverity issue.
>>
>> Coverity issue: 349932
>> Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> 

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

Patch

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 81e773046..efe515221 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -1401,7 +1401,7 @@  hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
 	struct hns3_mac_vlan_tbl_entry_cmd req;
 	struct hns3_pf *pf = &hns->pf;
-	struct hns3_cmd_desc desc;
+	struct hns3_cmd_desc desc[3];
 	char mac_str[RTE_ETHER_ADDR_FMT_SIZE];
 	uint16_t egress_port = 0;
 	uint8_t vf_id;
@@ -1435,7 +1435,7 @@  hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr)
 	 * it if the entry is inexistent. Repeated unicast entry
 	 * is not allowed in the mac vlan table.
 	 */
-	ret = hns3_lookup_mac_vlan_tbl(hw, &req, &desc, false);
+	ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, false);
 	if (ret == -ENOENT) {
 		if (!hns3_is_umv_space_full(hw)) {
 			ret = hns3_add_mac_vlan_tbl(hw, &req, NULL);