linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] net: fec: fix ref count leaking when pm_runtime_get_sync fails
@ 2020-06-14  8:25 Markus Elfring
  2020-06-14 15:30 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2020-06-14  8:25 UTC (permalink / raw)
  To: Navid Emamdoost, netdev
  Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, Qiushi Wu,
	David S. Miller, Fugang Duan, kernel-janitors, linux-kernel

> in fec_enet_mdio_read, …

I am curious under which circumstances you would like to improve
such commit messages.

* Will the tag “Fixes” become helpful?

* Which source code analysis tools did trigger to send
  update suggestions according to 16 similar issues for today?


…
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1893,8 +1895,10 @@  static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
>  	bool is_c45 = !!(regnum & MII_ADDR_C45);
>
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put_autosuspend(dev);
>  		return ret;
> +	}
>  	else
>  		ret = 0;

I suggest to adjust also the source code from the else branch.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=96144c58abe7ff767e754b5b80995f7b8846d49b#n196> @@ -2276,6 +2280,7 @@  static void fec_enet_get_regs(struct net_device *ndev,
>  	}
>
>  	pm_runtime_mark_last_busy(dev);
> +out:
>  	pm_runtime_put_autosuspend(dev);
>  }

Perhaps use the label “put_runtime” instead?

Regards,
Markus

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

* Re: [PATCH] net: fec: fix ref count leaking when pm_runtime_get_sync fails
  2020-06-14  8:25 [PATCH] net: fec: fix ref count leaking when pm_runtime_get_sync fails Markus Elfring
@ 2020-06-14 15:30 ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2020-06-14 15:30 UTC (permalink / raw)
  To: Markus Elfring
  Cc: Navid Emamdoost, netdev, Navid Emamdoost, Kangjie Lu,
	Stephen McCamant, Qiushi Wu, David S. Miller, Fugang Duan,
	kernel-janitors, linux-kernel

On Sun, Jun 14, 2020 at 10:25:38AM +0200, Markus Elfring wrote:
> > in fec_enet_mdio_read, …
> 
> I am curious under which circumstances you would like to improve
> such commit messages.
> 
> * Will the tag “Fixes” become helpful?
> 
> * Which source code analysis tools did trigger to send
>   update suggestions according to 16 similar issues for today?
> 

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless
review comment to a patch submission on a Linux kernel developer mailing
list.  I strongly suggest that you not do this anymore.  Please do not
bother developers who are actively working to produce patches and
features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to
follow it at all.  The person/bot/AI that sent it is being ignored by
almost all Linux kernel maintainers for having a persistent pattern of
behavior of producing distracting and pointless commentary, and
inability to adapt to feedback.  Please feel free to also ignore emails
from them.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH] net: fec: fix ref count leaking when pm_runtime_get_sync fails
  2020-06-14  5:38 Navid Emamdoost
@ 2020-06-15 20:42 ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-06-15 20:42 UTC (permalink / raw)
  To: navid.emamdoost
  Cc: fugang.duan, netdev, linux-kernel, emamd001, wu000273, kjlu, mccamant

From: Navid Emamdoost <navid.emamdoost@gmail.com>
Date: Sun, 14 Jun 2020 00:38:01 -0500

> in fec_enet_mdio_read, fec_enet_mdio_write, fec_enet_get_regs,
> fec_enet_open and fec_drv_remove, pm_runtime_get_sync is called which
> increments the counter even in case of failure, leading to incorrect
> ref count. In case of failure, decrement the ref count before returning.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

This does not apply to the net tree.

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

* [PATCH] net: fec: fix ref count leaking when pm_runtime_get_sync fails
@ 2020-06-14  5:38 Navid Emamdoost
  2020-06-15 20:42 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Navid Emamdoost @ 2020-06-14  5:38 UTC (permalink / raw)
  To: Fugang Duan, David S. Miller, netdev, linux-kernel
  Cc: emamd001, wu000273, kjlu, mccamant, Navid Emamdoost

in fec_enet_mdio_read, fec_enet_mdio_write, fec_enet_get_regs,
fec_enet_open and fec_drv_remove, pm_runtime_get_sync is called which
increments the counter even in case of failure, leading to incorrect
ref count. In case of failure, decrement the ref count before returning.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index dc6f8763a5d4..a33012b89cc9 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1827,8 +1827,10 @@ static int fec_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 	bool is_c45 = !!(regnum & MII_ADDR_C45);
 
 	ret = pm_runtime_get_sync(dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_autosuspend(dev);
 		return ret;
+	}
 
 	reinit_completion(&fep->mdio_done);
 
@@ -1893,8 +1895,10 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 	bool is_c45 = !!(regnum & MII_ADDR_C45);
 
 	ret = pm_runtime_get_sync(dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_autosuspend(dev);
 		return ret;
+	}
 	else
 		ret = 0;
 
@@ -2258,7 +2262,7 @@ static void fec_enet_get_regs(struct net_device *ndev,
 
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0)
-		return;
+		goto out;
 
 	regs->version = fec_enet_register_version;
 
@@ -2276,6 +2280,7 @@ static void fec_enet_get_regs(struct net_device *ndev,
 	}
 
 	pm_runtime_mark_last_busy(dev);
+out:
 	pm_runtime_put_autosuspend(dev);
 }
 
@@ -2952,8 +2957,10 @@ fec_enet_open(struct net_device *ndev)
 	bool reset_again;
 
 	ret = pm_runtime_get_sync(&fep->pdev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_autosuspend(&fep->pdev->dev);
 		return ret;
+	}
 
 	pinctrl_pm_select_default_state(&fep->pdev->dev);
 	ret = fec_enet_clk_enable(ndev, true);
@@ -3741,8 +3748,10 @@ fec_drv_remove(struct platform_device *pdev)
 	int ret;
 
 	ret = pm_runtime_get_sync(&pdev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
+	}
 
 	cancel_work_sync(&fep->tx_timeout_work);
 	fec_ptp_stop(pdev);
-- 
2.17.1


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

end of thread, other threads:[~2020-06-15 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-14  8:25 [PATCH] net: fec: fix ref count leaking when pm_runtime_get_sync fails Markus Elfring
2020-06-14 15:30 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2020-06-14  5:38 Navid Emamdoost
2020-06-15 20:42 ` David Miller

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