From: Johan Hovold <johan@kernel.org> Date: 2016-11-24 18:22:51
This series fixes a number of phydev reference leaks (and one of_node
leak) due to failure to put the reference taken by of_phy_find_device().
Note that I did not try to fix drivers/net/phy/xilinx_gmii2rgmii.c which
still leaks a reference.
Against net but should apply just as fine to net-next.
Thanks,
Johan
v2:
- use put_device() instead of phy_dev_free() to put the references
taken in net/dsa (patch 1/4).
- add four new patches fixing similar leaks
Johan Hovold (5):
net: dsa: fix fixed-link-phy device leaks
net: bcmgenet: fix phydev reference leak
net: fsl/fman: fix phydev reference leak
net: fsl/fman: fix fixed-link-phydev reference leak
net: qcom/emac: fix of_node and phydev leaks
drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 +++-
drivers/net/ethernet/freescale/fman/fman_memac.c | 3 +++
drivers/net/ethernet/freescale/fman/mac.c | 2 ++
drivers/net/ethernet/qualcomm/emac/emac-phy.c | 1 +
drivers/net/ethernet/qualcomm/emac/emac.c | 4 ++++
net/dsa/dsa.c | 5 ++++-
6 files changed, 17 insertions(+), 2 deletions(-)
--
2.7.3
From: Johan Hovold <johan@kernel.org> Date: 2016-11-24 18:22:50
Make sure to drop the reference taken by of_phy_find_device() when
registering and deregistering the fixed-link PHY-device.
Fixes: 39b0c705195e ("net: dsa: Allow configuration of CPU & DSA port
speeds/duplex")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
net/dsa/dsa.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
From: Johan Hovold <johan@kernel.org> Date: 2016-11-24 18:22:53
Make sure to drop the reference taken by of_phy_find_device() when
initialising MOCA PHYs.
Fixes: 6ac9de5f6563 ("net: bcmgenet: Register link_update callback for
all MoCA PHYs")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
@@ -542,8 +542,10 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)/* Make sure we initialize MoCA PHYs with a link down */if(phy_mode==PHY_INTERFACE_MODE_MOCA){phydev=of_phy_find_device(dn);-if(phydev)+if(phydev){phydev->link=0;+put_device(&phydev->mdio.dev);+}}return0;
From: Johan Hovold <johan@kernel.org> Date: 2016-11-24 18:22:55
Make sure to drop the reference taken by of_phy_find_device() when
looking up a fixed-link phydev during probe.
Fixes: 57ba4c9b56d8 ("fsl/fman: Add FMan MAC support")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/ethernet/freescale/fman/mac.c | 2 ++
1 file changed, 2 insertions(+)
From: Johan Hovold <johan@kernel.org> Date: 2016-11-24 18:23:44
Make sure to drop the reference taken by of_phy_find_device() during
probe on probe errors and on driver unbind.
Also drop the of_node reference taken by of_parse_phandle() in the same
path.
Fixes: b9b17debc69d ("net: emac: emac gigabit ethernet controller driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/ethernet/qualcomm/emac/emac-phy.c | 1 +
drivers/net/ethernet/qualcomm/emac/emac.c | 4 ++++
2 files changed, 5 insertions(+)
From: Johan Hovold <johan@kernel.org> Date: 2016-11-24 18:24:12
Make sure to drop the reference taken by of_phy_find_device() during
initialisation when later freeing the struct fman_mac.
Fixes: 57ba4c9b56d8 ("fsl/fman: Add FMan MAC support")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/ethernet/freescale/fman/fman_memac.c | 3 +++
1 file changed, 3 insertions(+)
From: Timur Tabi <hidden> Date: 2016-11-24 18:55:35
Johan Hovold wrote:
Make sure to drop the reference taken by of_phy_find_device() during
probe on probe errors and on driver unbind.
Also drop the of_node reference taken by of_parse_phandle() in the same
path.
Fixes: b9b17debc69d ("net: emac: emac gigabit ethernet controller driver")
Signed-off-by: Johan Hovold<johan@kernel.org>
When I first wrote this code, I had a lot of trouble getting the PHY to
re-probe when the driver was unloaded and reloaded, and it was because
of some odd problems with get/put of of_nodes.
Since I know that you didn't test this driver on real hardware, I have
to test these patches myself before I can ACK them.
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
-----Original Message-----
From: Johan Hovold [mailto:jhovold@gmail.com] On Behalf Of Johan Hovold
Sent: Thursday, November 24, 2016 8:22 PM
Make sure to drop the reference taken by of_phy_find_device() when
looking up a fixed-link phydev during probe.
Fixes: 57ba4c9b56d8 ("fsl/fman: Add FMan MAC support")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/ethernet/freescale/fman/mac.c | 2 ++
1 file changed, 2 insertions(+)
From: David Miller <davem@davemloft.net> Date: 2016-11-28 01:03:12
From: Johan Hovold <johan@kernel.org>
Date: Thu, 24 Nov 2016 19:21:26 +0100
This series fixes a number of phydev reference leaks (and one of_node
leak) due to failure to put the reference taken by of_phy_find_device().
Note that I did not try to fix drivers/net/phy/xilinx_gmii2rgmii.c which
still leaks a reference.
Against net but should apply just as fine to net-next.
...
v2:
- use put_device() instead of phy_dev_free() to put the references
taken in net/dsa (patch 1/4).
- add four new patches fixing similar leaks
From: Timur Tabi <hidden> Date: 2016-11-28 02:11:24
David Miller wrote:
Series applied, thanks.
I was really hoping you'd give me the chance to test the patches before
applying them.
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the
Code Aurora Forum, hosted by The Linux Foundation.
From: Timur Tabi <hidden> Date: 2017-01-09 19:49:57
On 11/24/2016 12:21 PM, Johan Hovold wrote:
+ if (!has_acpi_companion(&pdev->dev))
+ put_device(&adpt->phydev->mdio.dev);
I was wondering if, instead of calling put_device() only on non-ACPI systems,
would it be better if on an ACPI system I called get_device() manually? That
is, some thing like this:
int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
{
...
if (has_acpi_companion(&pdev->dev)) {
...
get_device(&mii_bus->dev);
} else {
...
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
From: Johan Hovold <johan@kernel.org> Date: 2017-01-10 08:43:33
On Mon, Jan 09, 2017 at 01:49:53PM -0600, Timur Tabi wrote:
On 11/24/2016 12:21 PM, Johan Hovold wrote:
quoted
+ if (!has_acpi_companion(&pdev->dev))
+ put_device(&adpt->phydev->mdio.dev);
I was wondering if, instead of calling put_device() only on non-ACPI systems,
would it be better if on an ACPI system I called get_device() manually? That
is, some thing like this:
int emac_phy_config(struct platform_device *pdev, struct emac_adapter *adpt)
{
...
if (has_acpi_companion(&pdev->dev)) {
...
get_device(&mii_bus->dev);
} else {
...