Commit 31166efb authored by Alexander Duyck's avatar Alexander Duyck Committed by Tony Nguyen
Browse files

ixgbe: Fix NULL pointer dereference in ethtool loopback test



The ixgbe driver currently generates a NULL pointer dereference when
performing the ethtool loopback test. This is due to the fact that there
isn't a q_vector associated with the test ring when it is setup as
interrupts are not normally added to the test rings.

To address this I have added code that will check for a q_vector before
returning a napi_id value. If a q_vector is not present it will return a
value of 0.

Fixes: b02e5a0e ("xsk: Propagate napi_id to XDP socket Rx path")
Signed-off-by: default avatarAlexander Duyck <alexanderduyck@fb.com>
Acked-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Tested-by: default avatarDave Switzer <david.switzer@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent ccb39c62
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -6536,6 +6536,13 @@ static int ixgbe_setup_all_tx_resources(struct ixgbe_adapter *adapter)
	return err;
}

static int ixgbe_rx_napi_id(struct ixgbe_ring *rx_ring)
{
	struct ixgbe_q_vector *q_vector = rx_ring->q_vector;

	return q_vector ? q_vector->napi.napi_id : 0;
}

/**
 * ixgbe_setup_rx_resources - allocate Rx resources (Descriptors)
 * @adapter: pointer to ixgbe_adapter
@@ -6583,7 +6590,7 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,

	/* XDP RX-queue info */
	if (xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev,
			     rx_ring->queue_index, rx_ring->q_vector->napi.napi_id) < 0)
			     rx_ring->queue_index, ixgbe_rx_napi_id(rx_ring)) < 0)
		goto err;

	rx_ring->xdp_prog = adapter->xdp_prog;