netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open()
@ 2022-12-08 10:55 Roger Quadros
  2022-12-10  0:54 ` Saeed Mahameed
  2022-12-12 21:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Roger Quadros @ 2022-12-08 10:55 UTC (permalink / raw)
  To: davem, maciej.fijalkowski, kuba
  Cc: andrew, edumazet, pabeni, vigneshr, s-vadapalli, linux-omap,
	netdev, linux-kernel, Roger Quadros

Ensure pm_runtime_put() is issued in error path.

Reported-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index b8f7080434cb..58c20e4c0e9f 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -573,20 +573,21 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
 	reg = cpsw_sl_reg_read(port->slave.mac_sl, CPSW_SL_SOFT_RESET);
 	if (reg) {
 		dev_err(common->dev, "soft RESET didn't complete\n");
-		return -ETIMEDOUT;
+		ret = -ETIMEDOUT;
+		goto runtime_put;
 	}
 
 	/* Notify the stack of the actual queue counts. */
 	ret = netif_set_real_num_tx_queues(ndev, common->tx_ch_num);
 	if (ret) {
 		dev_err(common->dev, "cannot set real number of tx queues\n");
-		return ret;
+		goto runtime_put;
 	}
 
 	ret = netif_set_real_num_rx_queues(ndev, AM65_CPSW_MAX_RX_QUEUES);
 	if (ret) {
 		dev_err(common->dev, "cannot set real number of rx queues\n");
-		return ret;
+		goto runtime_put;
 	}
 
 	for (i = 0; i < common->tx_ch_num; i++)
@@ -594,7 +595,7 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
 
 	ret = am65_cpsw_nuss_common_open(common);
 	if (ret)
-		return ret;
+		goto runtime_put;
 
 	common->usage_count++;
 
@@ -622,6 +623,10 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
 error_cleanup:
 	am65_cpsw_nuss_ndo_slave_stop(ndev);
 	return ret;
+
+runtime_put:
+	pm_runtime_put(common->dev);
+	return ret;
 }
 
 static void am65_cpsw_nuss_rx_cleanup(void *data, dma_addr_t desc_dma)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open()
  2022-12-08 10:55 [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open() Roger Quadros
@ 2022-12-10  0:54 ` Saeed Mahameed
  2022-12-12  9:20   ` Roger Quadros
  2022-12-12 21:00 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Saeed Mahameed @ 2022-12-10  0:54 UTC (permalink / raw)
  To: Roger Quadros
  Cc: davem, maciej.fijalkowski, kuba, andrew, edumazet, pabeni,
	vigneshr, s-vadapalli, linux-omap, netdev, linux-kernel

On 08 Dec 12:55, Roger Quadros wrote:
>Ensure pm_runtime_put() is issued in error path.
>
>Reported-by: Jakub Kicinski <kuba@kernel.org>
>Signed-off-by: Roger Quadros <rogerq@kernel.org>


Reviewed-by: Saeed Mahameed <saeed@kernel.org>


[...]

>@@ -622,6 +623,10 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
> error_cleanup:
> 	am65_cpsw_nuss_ndo_slave_stop(ndev);

BTW, while looking at the ndo_slave_stop() call, it seems to abort if 
am65_cpsw_nuss_common_stop() fails, but looking deeper at that and it seems 
am65_cpsw_nuss_common_stop() can never fail, so you might want to fix that.

> 	return ret;
>+
>+runtime_put:
>+	pm_runtime_put(common->dev);
>+	return ret;
> }
>
> static void am65_cpsw_nuss_rx_cleanup(void *data, dma_addr_t desc_dma)
>-- 
>2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open()
  2022-12-10  0:54 ` Saeed Mahameed
@ 2022-12-12  9:20   ` Roger Quadros
  0 siblings, 0 replies; 4+ messages in thread
From: Roger Quadros @ 2022-12-12  9:20 UTC (permalink / raw)
  To: Saeed Mahameed
  Cc: davem, maciej.fijalkowski, kuba, andrew, edumazet, pabeni,
	vigneshr, s-vadapalli, linux-omap, netdev, linux-kernel



On 10/12/2022 02:54, Saeed Mahameed wrote:
> On 08 Dec 12:55, Roger Quadros wrote:
>> Ensure pm_runtime_put() is issued in error path.
>>
>> Reported-by: Jakub Kicinski <kuba@kernel.org>
>> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> 
> 
> Reviewed-by: Saeed Mahameed <saeed@kernel.org>
> 
> 
> [...]
> 
>> @@ -622,6 +623,10 @@ static int am65_cpsw_nuss_ndo_slave_open(struct net_device *ndev)
>> error_cleanup:
>>     am65_cpsw_nuss_ndo_slave_stop(ndev);
> 
> BTW, while looking at the ndo_slave_stop() call, it seems to abort if am65_cpsw_nuss_common_stop() fails, but looking deeper at that and it seems am65_cpsw_nuss_common_stop() can never fail, so you might want to fix that.

You mean we should change it to return void and get rid of error checks on that function. Right?

> 
>>     return ret;
>> +
>> +runtime_put:
>> +    pm_runtime_put(common->dev);
>> +    return ret;
>> }
>>
>> static void am65_cpsw_nuss_rx_cleanup(void *data, dma_addr_t desc_dma)
>> -- 
>> 2.34.1
>>

cheers,
-roger

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open()
  2022-12-08 10:55 [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open() Roger Quadros
  2022-12-10  0:54 ` Saeed Mahameed
@ 2022-12-12 21:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-12 21:00 UTC (permalink / raw)
  To: Roger Quadros
  Cc: davem, maciej.fijalkowski, kuba, andrew, edumazet, pabeni,
	vigneshr, s-vadapalli, linux-omap, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  8 Dec 2022 12:55:34 +0200 you wrote:
> Ensure pm_runtime_put() is issued in error path.
> 
> Reported-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Roger Quadros <rogerq@kernel.org>
> ---
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)

Here is the summary with links:
  - [net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open()
    https://git.kernel.org/netdev/net-next/c/5821504f5073

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-12 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-08 10:55 [PATCH net-next] net: ethernet: ti: am65-cpsw: Fix PM runtime leakage in am65_cpsw_nuss_ndo_slave_open() Roger Quadros
2022-12-10  0:54 ` Saeed Mahameed
2022-12-12  9:20   ` Roger Quadros
2022-12-12 21:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).