Subject: RE: [PATCH net-next v2 2/3] net: txgbe: support Flow Director perfect filters

From: Jiawen Wu <[email-masked]>
Date: Tue, 18 Jun 2024 17:07:42 +0800

> > > +	/* only program filters to hardware if the net device is running, as
> > > +	 * we store the filters in the Rx buffer which is not allocated when
> > > +	 * the device is down
> > > +	 */
> > > +	if (netif_running(wx->netdev)) {
> > > +		err = txgbe_fdir_write_perfect_filter(wx, &input->filter,
> > > +						      input->sw_idx, queue);
> > > +		if (err)
> > > +			goto err_unlock;
> > > +	}
> > > +
> > > +	txgbe_update_ethtool_fdir_entry(txgbe, input, input->sw_idx);
> > > +
> > > +	spin_unlock(&txgbe->fdir_perfect_lock);
> > > +
> > > +	return err;
> >
> > Hi Jiawen Wu,
> >
> > Smatch flags that err may be used uninitialised here.
> > I'm unsure if that can occur in practice, but perhaps it
> > would be nicer to simply return 0 here.

Perhaps initialize err = -EINVAL, and return 0 here.

> >
> > > +err_unlock:
> > > +	spin_unlock(&txgbe->fdir_perfect_lock);
> > > +err_out:
> > > +	kfree(input);
> > > +	return -EINVAL;
> >
> > And conversely, perhaps it would be nicer to return err here - ensuring is
> > it always set.  F.e. this would propagate the error code returned by
> > txgbe_fdir_write_perfect_filter().
> 
> I think it can be changed to initialize err = 0, and return err in these two places.

Then return err here.