From: Shaozhengchao <shaozhengchao(a)huawei.com>
commit 76633858616206db7ec5331d152f45b2dea8761e openEuler-1.0
driver inclusion
category:bugfix
bugzilla:4472
CVE:NA
-----------------------------------------------------------------------
fix return value bug
Signed-off-by: Shaozhengchao <shaozhengchao(a)huawei.com>
Reviewed-by: Wangxiaoyun <wangxiaoyun(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
Signed-off-by: Xin Hao <haoxing990(a)gmail.com>
---
drivers/net/ethernet/huawei/hinic/hinic_cfg.c | 2 +-
drivers/net/ethernet/huawei/hinic/hinic_dcb.c | 6 +++---
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c | 4 ++--
drivers/net/ethernet/huawei/hinic/hinic_mgmt.c | 2 +-
drivers/net/ethernet/huawei/hinic/hinic_nictool.c | 13 ++++++-------
drivers/net/ethernet/huawei/hinic/hinic_rx.c | 2 +-
drivers/net/ethernet/huawei/hinic/hinic_tx.c | 4 ++--
drivers/net/ethernet/huawei/hinic/hinic_tx.h | 2 +-
8 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_cfg.c
b/drivers/net/ethernet/huawei/hinic/hinic_cfg.c
index 6662119f684b..b2599b5c20cd 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_cfg.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_cfg.c
@@ -610,7 +610,7 @@ static int get_cap_from_pf(struct hinic_hwdev *dev, enum func_type
type)
if (err || dev_cap.status || !out_len) {
sdk_err(dev->dev_hdl, "Failed to get capability from PF, err: %d, status:
0x%x, out size: 0x%x\n",
err, dev_cap.status, out_len);
- return err;
+ return -EFAULT;
}
parse_dev_cap(dev, &dev_cap, type);
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_dcb.c
b/drivers/net/ethernet/huawei/hinic/hinic_dcb.c
index 0cbdb7b7179f..75a769b54ab1 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_dcb.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_dcb.c
@@ -1744,7 +1744,7 @@ int hinic_set_cos_up_map(struct hinic_nic_dev *nic_dev, u8 *cos_up)
struct hinic_nic_dev *tmp_dev;
u8 num_cos, old_cos_up[HINIC_DCB_COS_MAX] = {0};
u32 i, idx, num_dev = 0;
- int err;
+ int err, rollback_err;
/* Save old map, in case of set failed */
err = hinic_get_cos_up_map(nic_dev, &num_cos, old_cos_up);
@@ -1792,8 +1792,8 @@ int hinic_set_cos_up_map(struct hinic_nic_dev *nic_dev, u8 *cos_up)
/* undo all settings */
for (i = 0; i < idx; i++) {
tmp_dev = (struct hinic_nic_dev *)uld_array[i];
- err = __set_cos_up_map(tmp_dev, old_cos_up);
- if (err)
+ rollback_err = __set_cos_up_map(tmp_dev, old_cos_up);
+ if (rollback_err)
nicif_err(tmp_dev, drv, tmp_dev->netdev,
"Undo cos_up map to hw failed\n");
}
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
index 9c28fb66822d..ad9faab1a450 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
@@ -745,12 +745,12 @@ static int hinic_set_settings_to_hw(struct hinic_nic_dev *nic_dev,
char set_link_str[128] = {0};
int err = 0;
- snprintf(set_link_str, sizeof(set_link_str) - 1, "%s",
+ snprintf(set_link_str, sizeof(set_link_str), "%s",
(set_settings & HILINK_LINK_SET_AUTONEG) ?
(autoneg ? "autong enable " : "autong disable ") : "");
if (set_settings & HILINK_LINK_SET_SPEED) {
speed_level = hinic_ethtool_to_hw_speed_level(speed);
- snprintf(set_link_str, sizeof(set_link_str) - 1,
+ snprintf(set_link_str, sizeof(set_link_str),
"%sspeed %d ", set_link_str, speed);
}
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c
b/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c
index 8706ef016ccb..119155b8a158 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_mgmt.c
@@ -383,7 +383,7 @@ static int send_msg_to_mgmt_sync(struct hinic_msg_pf_to_mgmt
*pf_to_mgmt,
if (!hinic_get_chip_present_flag(pf_to_mgmt->hwdev))
return -EFAULT;
- if (cmd_size > MAX_CMD_BUF_SIZE)
+ if (cmd_size > MAX_MSG_SZ)
return -EFAULT;
if (direction == HINIC_MSG_RESPONSE)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nictool.c
b/drivers/net/ethernet/huawei/hinic/hinic_nictool.c
index f611b8b26202..f281c19a275b 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_nictool.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_nictool.c
@@ -586,10 +586,7 @@ static int get_loopback_mode(struct hinic_nic_dev *nic_dev, void
*buf_in,
}
err = hinic_get_loopback_mode_ex(nic_dev->hwdev, &mode->loop_mode,
&mode->loop_ctrl);
- if (err)
- return err;
-
- return 0;
+ return err;
}
static int set_loopback_mode(struct hinic_nic_dev *nic_dev, void *buf_in,
@@ -1548,9 +1545,10 @@ static int send_to_nic_driver(struct hinic_nic_dev *nic_dev,
}
mutex_unlock(&nic_dev->nic_mutex);
- if (index == num_cmds)
+ if (index == num_cmds) {
pr_err("Can't find callback for %d\n", cmd_type);
-
+ return -EINVAL;
+ }
return err;
}
@@ -1899,7 +1897,7 @@ static bool is_hwdev_cmd_support(unsigned int mod,
break;
default:
- break;
+ return false;
}
return true;
@@ -2377,6 +2375,7 @@ int nictool_k_init(void)
g_dev_id, NULL, HIADM_DEV_NAME);
if (IS_ERR(pdevice)) {
pr_err("Export nictool device information to user space fail\n");
+ ret = -EFAULT;
goto device_create_err;
}
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
index 0564c9efcf16..9b0a37847792 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
@@ -672,7 +672,7 @@ int hinic_rx_poll(struct hinic_rxq *rxq, int budget)
bool bp_en = false;
u16 num_wqe = 0;
- while (unlikely(pkts < budget)) {
+ while (likely(pkts < budget)) {
sw_ci = ((u32)rxq->cons_idx) & rxq->q_mask;
rx_cqe = rxq->rx_info[sw_ci].cqe;
status = be32_to_cpu(rx_cqe->status);
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
index af51b59d5248..dcc48847d8ef 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
@@ -1275,7 +1275,7 @@ int hinic_stop_sq(struct hinic_txq *txq)
return -EFAULT;
}
-int hinic_flush_txqs(struct net_device *netdev)
+void hinic_flush_txqs(struct net_device *netdev)
{
struct hinic_nic_dev *nic_dev = netdev_priv(netdev);
u16 qid;
@@ -1288,5 +1288,5 @@ int hinic_flush_txqs(struct net_device *netdev)
"Failed to stop sq%d\n", qid);
}
- return 0;
+ return;
} /*lint -e766*/
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.h
b/drivers/net/ethernet/huawei/hinic/hinic_tx.h
index 04aeb3365cca..2a01fabdfcbe 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_tx.h
+++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.h
@@ -119,6 +119,6 @@ int hinic_tx_poll(struct hinic_txq *txq, int budget);
u8 hinic_get_vlan_pri(struct sk_buff *skb);
-int hinic_flush_txqs(struct net_device *netdev);
+void hinic_flush_txqs(struct net_device *netdev);
#endif
--
2.31.0