public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Martin Habets <habetsm.xilinx@gmail•com>
To: Yi Yang <yiyang13@huawei•com>
Cc: ecree.xilinx@gmail•com, davem@davemloft•net, edumazet@google•com,
	kuba@kernel•org, pabeni@redhat•com, vladimir.oltean@nxp•com,
	alex.austin@amd•com, netdev@vger•kernel.org,
	linux-net-drivers@amd•com
Subject: Re: [PATCH v2 -next] sfc: Add missing pci_disable_device() for error path
Date: Thu, 15 Aug 2024 09:21:12 +0100	[thread overview]
Message-ID: <20240815082112.GA35524@gmail.com> (raw)
In-Reply-To: <20240815030436.1373868-1-yiyang13@huawei.com>

On Thu, Aug 15, 2024 at 03:04:36AM +0000, Yi Yang wrote:
> This error path needs to disable the pci device before returning.

Can you explain why this is needed? What goes wrong without this patch?

> 
> Fixes: 6e173d3b4af9 ("sfc: Copy shared files needed for Siena (part 1)")
> Fixes: 5a6681e22c14 ("sfc: separate out SFC4000 ("Falcon") support into new sfc-falcon driver")
> Fixes: 89c758fa47b5 ("sfc: Add power-management and wake-on-LAN support")
> Signed-off-by: Yi Yang <yiyang13@huawei•com>
> ---
> 
> v2: add pci_disable_device() for efx_pm_resume() (drivers/net/ethernet/sfc/efx.c)
> and ef4_pm_resume() (drivers/net/ethernet/sfc/falcon/efx.c)
> 
>  drivers/net/ethernet/sfc/efx.c        | 6 ++++--
>  drivers/net/ethernet/sfc/falcon/efx.c | 6 ++++--
>  drivers/net/ethernet/sfc/siena/efx.c  | 6 ++++--
>  3 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
> index 6f1a01ded7d4..bf6567093001 100644
> --- a/drivers/net/ethernet/sfc/efx.c
> +++ b/drivers/net/ethernet/sfc/efx.c
> @@ -1278,13 +1278,15 @@ static int efx_pm_resume(struct device *dev)
>  	pci_set_master(efx->pci_dev);
>  	rc = efx->type->reset(efx, RESET_TYPE_ALL);
>  	if (rc)
> -		return rc;
> +		goto fail;
>  	down_write(&efx->filter_sem);
>  	rc = efx->type->init(efx);
>  	up_write(&efx->filter_sem);
>  	if (rc)
> -		return rc;
> +		goto fail;
>  	rc = efx_pm_thaw(dev);

This always falls through into the failure path, even if efx_pm_thaw
succeeds.
Same for the other files.

Martin

> +fail:
> +	pci_disable_device(pci_dev);
>  	return rc;
>  }
>  
> diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c
> index 8925745f1c17..2c3cf1c9a1a7 100644
> --- a/drivers/net/ethernet/sfc/falcon/efx.c
> +++ b/drivers/net/ethernet/sfc/falcon/efx.c
> @@ -3027,11 +3027,13 @@ static int ef4_pm_resume(struct device *dev)
>  	pci_set_master(efx->pci_dev);
>  	rc = efx->type->reset(efx, RESET_TYPE_ALL);
>  	if (rc)
> -		return rc;
> +		goto fail;
>  	rc = efx->type->init(efx);
>  	if (rc)
> -		return rc;
> +		goto fail;
>  	rc = ef4_pm_thaw(dev);
> +fail:
> +	pci_disable_device(pci_dev);
>  	return rc;
>  }
>  
> diff --git a/drivers/net/ethernet/sfc/siena/efx.c b/drivers/net/ethernet/sfc/siena/efx.c
> index 59d3a6043379..dce9a5174e4a 100644
> --- a/drivers/net/ethernet/sfc/siena/efx.c
> +++ b/drivers/net/ethernet/sfc/siena/efx.c
> @@ -1240,13 +1240,15 @@ static int efx_pm_resume(struct device *dev)
>  	pci_set_master(efx->pci_dev);
>  	rc = efx->type->reset(efx, RESET_TYPE_ALL);
>  	if (rc)
> -		return rc;
> +		goto fail;
>  	down_write(&efx->filter_sem);
>  	rc = efx->type->init(efx);
>  	up_write(&efx->filter_sem);
>  	if (rc)
> -		return rc;
> +		goto fail;
>  	rc = efx_pm_thaw(dev);
> +fail:
> +	pci_disable_device(pci_dev);
>  	return rc;
>  }
>  
> -- 
> 2.25.1
> 

  reply	other threads:[~2024-08-15  8:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15  3:04 [PATCH v2 -next] sfc: Add missing pci_disable_device() for error path Yi Yang
2024-08-15  8:21 ` Martin Habets [this message]
2024-08-15  8:37   ` yiyang (D)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240815082112.GA35524@gmail.com \
    --to=habetsm.xilinx@gmail$(echo .)com \
    --cc=alex.austin@amd$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=ecree.xilinx@gmail$(echo .)com \
    --cc=edumazet@google$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux-net-drivers@amd$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=vladimir.oltean@nxp$(echo .)com \
    --cc=yiyang13@huawei$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox