diff options
author | Huazhong Tan <tanhuazhong@huawei.com> | 2019-02-02 17:39:32 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-02 19:24:08 +0300 |
commit | b6b4f987c5c4fe488f3f68460b9addc08482b164 (patch) | |
tree | e25bc772cd02a91c5f97695de5d4113f3ed2427f /drivers/net/ethernet/hisilicon | |
parent | 3a586422a5533a6c78376a779860f48ed72b9d83 (diff) | |
download | linux-b6b4f987c5c4fe488f3f68460b9addc08482b164.tar.xz |
net: hns3: fix a wrong checking in the hclge_tx_buffer_calc()
Only the TC is enabled, we need to check whether the buffer is enough,
otherwise it may lead to a wrong -ENOMEM case.
Fixes: 9ffe79a9c2ee ("net: hns3: Support for dynamically assigning tx buffer to TC")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/hisilicon')
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index a037dc5e36b7..5f6fc23fab5d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1506,13 +1506,14 @@ static int hclge_tx_buffer_calc(struct hclge_dev *hdev, for (i = 0; i < HCLGE_MAX_TC_NUM; i++) { struct hclge_priv_buf *priv = &buf_alloc->priv_buf[i]; - if (total_size < hdev->tx_buf_size) - return -ENOMEM; + if (hdev->hw_tc_map & BIT(i)) { + if (total_size < hdev->tx_buf_size) + return -ENOMEM; - if (hdev->hw_tc_map & BIT(i)) priv->tx_buf_size = hdev->tx_buf_size; - else + } else { priv->tx_buf_size = 0; + } total_size -= priv->tx_buf_size; } |