Subject: Re: [RFC PATCH v2 net-next 3/7] net: ethtool: record custom RSS contexts in the IDR

From: Jakub Kicinski <[email-masked]>
Date: Wed, 12 Apr 2023 18:49:27 -0700

On Tue, 11 Apr 2023 19:26:11 +0100 [email-masked] wrote:
>  	if (rxfh.rss_context)
>  		ret = ops->set_rxfh_context(dev, indir, hkey, rxfh.hfunc,
>  					    &rxfh.rss_context, delete);
> @@ -1350,6 +1377,40 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
>  		else if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE)
>  			dev->priv_flags |= IFF_RXFH_CONFIGURED;
>  	}

This is probably transient but I think we're potentially leaking @ctx
in a goto out hiding inside the context here, and...

> +	/* Update rss_ctx tracking */
> +	if (create) {
> +		/* Ideally this should happen before calling the driver,
> +		 * so that we can fail more cleanly; but we don't have the
> +		 * context ID until the driver picks it, so we have to
> +		 * wait until after.
> +		 */
> +		if (WARN_ON(idr_find(&dev->ethtool->rss_ctx, rxfh.rss_context)))
> +			/* context ID reused, our tracking is screwed */
> +			goto out;

here.