Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6b4f987 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller
Browse files

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: 9ffe79a9 ("net: hns3: Support for dynamically assigning tx buffer to TC")
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3a586422
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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 (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;
	}