Re: [PATCH v2 1/2] net/i40e: fix return value of close operation

Bruce Richardson <[email protected]>
Newsgroups org.dpdk.dev
Message-ID <[email protected]>
On Wed, Jul 15, 2026 at 02:48:15PM +0200, Sid Ali Cherrati wrote:
> rte_intr_callback_unregister() returns the number of unregistered
> callbacks on success. Since the close operation started returning
> the ret variable instead of 0, this positive value leaks as the
> return value of i40e_dev_close(), so applications checking
> rte_eth_dev_close() != 0 treat a successful close as a failure.
> 
> Use a separate cb_ret variable for the unregister return value so a
> successful unregister never clobbers an earlier error stored in ret,
> and stop retrying once unregister fails with anything other than
> -EAGAIN, since those errors are not transient.
> 
> Fixes: 62024eb82756 ("ethdev: change stop operation callback to return int")
> Cc: [email protected]
> 
> Signed-off-by: Sid Ali Cherrati <[email protected]>
Acked-by: Bruce Richardson <[email protected]>
> ---
> v2: use a temporary cb_ret variable instead of unconditionally zeroing
>     ret, and stop retrying on a non-transient unregister error, so an
>     earlier error is not lost or masked by a successful/failed
>     unregister
> 
>  drivers/net/intel/i40e/i40e_ethdev.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
> index b6b2d291ee..b5457bcf2e 100644
> --- a/drivers/net/intel/i40e/i40e_ethdev.c
> +++ b/drivers/net/intel/i40e/i40e_ethdev.c
> @@ -2693,6 +2693,7 @@ i40e_dev_close(struct rte_eth_dev *dev)
>  	uint32_t reg;
>  	int i;
>  	int ret;
> +	int cb_ret;

Since this value is only used inside do { } while, I think it's best to
just declare it there. Will adjust on apply unless there are objections.

>  	uint8_t aq_fail = 0;
>  	int retries = 0;
>  
> @@ -2761,14 +2762,17 @@ i40e_dev_close(struct rte_eth_dev *dev)
>  	i40e_pf_host_uninit(dev);
>  
>  	do {
> -		ret = rte_intr_callback_unregister(intr_handle,
> +		cb_ret = rte_intr_callback_unregister(intr_handle,
>  				i40e_dev_interrupt_handler, dev);
> -		if (ret >= 0 || ret == -ENOENT) {
> +		if (cb_ret >= 0 || cb_ret == -ENOENT) {
>  			break;
> -		} else if (ret != -EAGAIN) {
> +		} else if (cb_ret != -EAGAIN) {
>  			PMD_INIT_LOG(ERR,
>  				 "intr callback unregister failed: %d",
> -				 ret);
> +				 cb_ret);
> +			if (ret == 0)
> +				ret = cb_ret;
> +			break;
>  		}
>  		i40e_msec_delay(500);
>  	} while (retries++ < 5);
> -- 
> 2.34.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.