[PATCH net 2/2] hinic3: Fix partial RX buffer allocation check during queue setup

Fan Gong <[email protected]> Mon, 3 Aug 2026 11:48:25 +0800
Newsgroups org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <30b9c237a8a385bc949edf17693dae4f18803694.1785727595.git.tengpeisen@huawei.com>
From: Teng Peisen <[email protected]>

From: Fan Gong <[email protected]>

In hinic3_configure_rxqs(), the check for hinic3_rx_fill_buffers() only
verifies that at least one buffer was allocated (!pkts).

If memory allocation partially fails during RX queue setup, the function
incorrectly treats a partially populated RX ring as successful, which
may cause RX queue instability or unexpected packet drops at runtime.

Fix this by tightening the condition to 'pkts < rxq->q_mask'. This ensures
that RX queue configuration fails with -ENOMEM unless the RX ring is
completely filled as expected.

Fixes: b83bb584bc97 ("hinic3: Tx & Rx configuration")
Co-developed-by: Teng Peisen <[email protected]>
Signed-off-by: Teng Peisen <[email protected]>
Signed-off-by: Fan Gong <[email protected]>
---
 drivers/net/ethernet/huawei/hinic3/hinic3_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
index 309ab5901379..389b1c2158be 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
@@ -541,7 +541,7 @@ int hinic3_configure_rxqs(struct net_device *netdev, u16 num_rq,
 		rq_associate_cqes(rxq);
 
 		pkts = hinic3_rx_fill_buffers(rxq);
-		if (!pkts) {
+		if (pkts < rxq->q_mask) {
 			netdev_err(netdev, "Failed to fill Rx buffer\n");
 			return -ENOMEM;
 		}
-- 
2.54.0