Skip to content

Commit 85f4b0c

Browse files
Anshumali GaurPaolo Abeni
authored andcommitted
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: d45d897 ("octeontx2-pf: Add basic ethtool support") Signed-off-by: Anshumali Gaur <agaur@marvell.com> Link: https://patch.msgid.link/20251219062226.524844-1-agaur@marvell.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 4d14429 commit 85f4b0c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,14 @@ static int otx2_set_ringparam(struct net_device *netdev,
418418
*/
419419
if (rx_count < pfvf->hw.rq_skid)
420420
rx_count = pfvf->hw.rq_skid;
421+
422+
if (ring->rx_pending < 16) {
423+
netdev_err(netdev,
424+
"rx ring size %u invalid, min is 16\n",
425+
ring->rx_pending);
426+
return -EINVAL;
427+
}
428+
421429
rx_count = Q_COUNT(Q_SIZE(rx_count, 3));
422430

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

0 commit comments

Comments
 (0)