]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ice: fix potential NULL pointer deref in error path of ice_set_ringparam()
authorKohei Enju <kohei@enjuk.jp>
Fri, 17 Apr 2026 00:53:32 +0000 (17:53 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 18 Apr 2026 19:01:34 +0000 (12:01 -0700)
ice_set_ringparam nullifies tstamp_ring of temporary tx_rings, without
clearing ICE_TX_RING_FLAGS_TXTIME bit.
When ICE_TX_RING_FLAGS_TXTIME is set and the subsequent
ice_setup_tx_ring() call fails, a NULL pointer dereference could happen
in the unwinding sequence:

ice_clean_tx_ring()
-> ice_is_txtime_cfg() == true (ICE_TX_RING_FLAGS_TXTIME is set)
-> ice_free_tx_tstamp_ring()
  -> ice_free_tstamp_ring()
    -> tstamp_ring->desc (NULL deref)

Clear ICE_TX_RING_FLAGS_TXTIME bit to avoid the potential issue.

Note that this potential issue is found by manual code review.
Compile test only since unfortunately I don't have E830 devices.

Fixes: ccde82e90946 ("ice: add E830 Earliest TxTime First Offload support")
Signed-off-by: Kohei Enju <kohei@enjuk.jp>
Reviewed-by: Paul Greenwalt <paul.greenwalt@intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20260416-iwl-net-submission-2026-04-14-v2-8-686c33c9828d@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_ethtool.c

index e6a20af6f63de5d4cc88f9033e13ca53f1f43b68..f28416a707d77c60033c0ddc982b1a83f15a02f6 100644 (file)
@@ -3290,6 +3290,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring,
                tx_rings[i].desc = NULL;
                tx_rings[i].tx_buf = NULL;
                tx_rings[i].tstamp_ring = NULL;
+               clear_bit(ICE_TX_RING_FLAGS_TXTIME, tx_rings[i].flags);
                tx_rings[i].tx_tstamps = &pf->ptp.port.tx;
                err = ice_setup_tx_ring(&tx_rings[i]);
                if (err) {