Commit 85f4b0c6 authored by Anshumali Gaur's avatar Anshumali Gaur Committed by Paolo Abeni
Browse files

octeontx2-pf: fix "UBSAN: shift-out-of-bounds error"



This patch ensures that the RX ring size (rx_pending) is not
set below the permitted length. This avoids UBSAN
shift-out-of-bounds errors when users passes small or zero
ring sizes via ethtool -G.

Fixes: d45d8979 ("octeontx2-pf: Add basic ethtool support")
Signed-off-by: default avatarAnshumali Gaur <agaur@marvell.com>
Link: https://patch.msgid.link/20251219062226.524844-1-agaur@marvell.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 4d144297
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -418,6 +418,14 @@ static int otx2_set_ringparam(struct net_device *netdev,
	 */
	if (rx_count < pfvf->hw.rq_skid)
		rx_count =  pfvf->hw.rq_skid;

	if (ring->rx_pending < 16) {
		netdev_err(netdev,
			   "rx ring size %u invalid, min is 16\n",
			   ring->rx_pending);
		return -EINVAL;
	}

	rx_count = Q_COUNT(Q_SIZE(rx_count, 3));

	/* Due pipelining impact minimum 2000 unused SQ CQE's