diff mbox series

[v2,-next] sfc: Add missing pci_disable_device() for error path

Message ID 20240815030436.1373868-1-yiyang13@huawei.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v2,-next] sfc: Add missing pci_disable_device() for error path | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 11 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 49 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-08-15--12-00 (tests: 707)

Commit Message

Yi Yang Aug. 15, 2024, 3:04 a.m. UTC
This error path needs to disable the pci device before returning.

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(-)

Comments

Martin Habets Aug. 15, 2024, 8:21 a.m. UTC | #1
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
>
Yi Yang Aug. 15, 2024, 8:37 a.m. UTC | #2
On 2024/8/15 16:21, Martin Habets wrote:
> 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
>>
> .
> 
Sorry. This is a coccinelle warning, Not a problem that actually 
happened. Maybe it doesn't have to be fixed.

--
diff mbox series

Patch

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);
+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;
 }