On Tue, Nov 17, 2026 at 03:48:10PM +0100, Przemek Kitszel wrote:
> On 11/13/26 5:14 PM, Petr Oros wrote:
> > ice_set_channels() and the mqprio path of ice_setup_tc() test
> > cdev->adev before taking pf->adev_mutex and dereference it afterwards.
> > ice_unplug_aux_dev() clears the pointer under the mutex from the
> > service task, from ice_prepare_for_reset() and from the devlink RoCE
> > and iWARP parameter handlers, none of which hold the RTNL lock, so the
> > pointer can go away between the test and the device_lock() call.
> >
> > Take pf->adev_mutex first and test the pointer under it. Without a
> > device the mutex is released again and the rebuild runs unlocked as
> > before.
> >
> > Fixes: a6a0974aae42 ("ice: Prevent set_channel from changing queues while
> > RDMA active")
> > Fixes: 4b31fd4d77ff ("ice: Fix RDMA VSI removal during queue rebuild")
> > Reviewed-by: Aleksandr Loktionov <[email protected]>
> > Signed-off-by: Petr Oros <[email protected]>
> > ---
> > v3:
> > - rebased, Reviewed-by from Aleksandr
> >
> > v2: https://lore.kernel.org/all/[email protected]/
> > ---
> > drivers/net/ethernet/intel/ice/ice_ethtool.c | 22 +++++++++++++-------
> > drivers/net/ethernet/intel/ice/ice_main.c | 22 +++++++++++++-------
> > 2 files changed, 28 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > index 35dff5e937402d..910664b35b4d35 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> > @@ -3888,6 +3888,7 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi
> > *vsi, int req_rss_size)
> > static int ice_set_channels(struct net_device *dev, struct
> > ethtool_channels *ch)
> > {
> > struct ice_netdev_priv *np = netdev_priv(dev);
> > + struct auxiliary_device *adev = NULL;
> > struct ice_vsi *vsi = np->vsi;
> > struct ice_pf *pf = vsi->back;
> > int new_rx = 0, new_tx = 0;
> > @@ -3943,14 +3944,19 @@ static int ice_set_channels(struct net_device *dev,
> > struct ethtool_channels *ch)
> > return -EINVAL;
> > }
> > - if (pf->cdev_info && pf->cdev_info->adev) {
> > + if (pf->cdev_info) {
> > mutex_lock(&pf->adev_mutex);
>
> a small problem (less critical part of the last Medium issue raported by
> Sashiko for the next patch) is that pf->cdev_info is changing while not
> protected by adev_mutex, here we accidentally re-read it (instead of
> keeping a variable), but overall it is a bad smell, would be nice to
> have a wrapper that takes both locks, and only after the success callers
> will deref the protected stuff
>
> otherwise a pretty nice change! thank you for your continued effort!
>
> > - device_lock(&pf->cdev_info->adev->dev);
> > - locked = true;
> > - if (pf->cdev_info->adev->dev.driver) {
> > - netdev_err(dev, "Cannot change channels when RDMA is
> > active\n");
> > - ret = -EBUSY;
> > - goto adev_unlock;
> > + adev = pf->cdev_info->adev;
> > + if (adev) {
> > + device_lock(&adev->dev);
> > + locked = true;
> > + if (adev->dev.driver) {
This is the wrong way to check whether a driver is bound, use
device_is_bound().
Thanks