From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: David Miller <davem@davemloft.net>
Cc: f.fainelli@gmail.com, devicetree@vger.kernel.org,
frowand.list@gmail.com, grant.likely@linaro.org,
isubramanian@apm.com, kchudgar@apm.com,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, leoli@freescale.com,
michal.simek@xilinx.com, netdev@vger.kernel.org, rric@kernel.org,
robh+dt@kernel.org, soren.brinkmann@xilinx.com,
sgoutham@cavium.com, thomas.petazzoni@free-electrons.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] phy: fix of_mdio_find_bus() device refcount leak
Date: Mon, 21 Sep 2015 20:32:07 +0100 [thread overview]
Message-ID: <20150921193206.GU21084@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20150921.120159.326170798236851436.davem@davemloft.net>
On Mon, Sep 21, 2015 at 12:01:59PM -0700, David Miller wrote:
> From: Russell King <rmk+kernel@arm.linux.org.uk>
> Date: Fri, 18 Sep 2015 10:54:55 +0100
>
> > Update the comment, and arrange for the only user of this function
> > to drop this refcount when disposing of a reference to it.
>
> mdio_mux is not the only user of of_mdio_find_bus(), DSA uses it as
> well.
>
> So if anything this commit message is inaccurate.
Yes, I missed that as it wasn't under drivers/net. It doesn't change
the validity of this patch, the existing code is wrong and I'm not
introducing anything that makes the code any more wrong than it is.
I'll fix the commit message, and I'll fix the DSA code too but in a
separate patch. Thanks for pointing it out.
> I also wonder about this refcounting scheme.
It's the standard driver model refcounting rules that we've lived with
for about a decade, ever since the driver model was introduced by
Patrick Mochel.
> If you are going to drop the inner device reference, then we take the
> mdio bus returned from of_mdio_find_bus() what holds onto it and keeps
> it from disappearing on us?
>
> Don't we have to hold onto some reference count of some kind here?
In the case of the mdio mux code, I'm dropping the reference when
either (a) we've encountered an error during initialisation and we're
cleaning up, or (b) when the mdio mux code is being torn down after
the mdiomux bus has been unregistered and freed. In both cases, we're
done with the mdio bus that was returned from of_mdio_find_bus().
In case (a), the devres code will release the kmalloc'd memory when
mdio_mux_gpio_probe() or mdio_mux_mmioreg_probe() propagates the error
out of their probe() function.
I'm not sure why you think anything is wrong here - maybe it's the odd
code structure to the success path at the bottom of mdio_mux_init()?
--
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2015-09-21 19:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-18 9:46 [PATCH 0/7] Phy and mdiobus fixes Russell King - ARM Linux
2015-09-18 9:47 ` [PATCH 1/7] phy: fix of_mdio_find_bus() device refcount leak Russell King
2015-09-18 9:47 ` [PATCH 2/7] phy: fix mdiobus module safety Russell King
2015-09-18 9:47 ` [PATCH 3/7] phy: add proper phy struct device refcounting Russell King
2015-09-18 9:47 ` [PATCH 4/7] of_mdio: fix MDIO phy " Russell King
2015-09-18 9:47 ` [PATCH 5/7] net: fix phy refcounting in a bunch of drivers Russell King
2015-09-18 9:47 ` [PATCH 6/7] phy: fixed-phy: properly validate phy in fixed_phy_update_state() Russell King
2015-09-18 9:47 ` [PATCH 7/7] phy: add phy_device_remove() Russell King
2015-09-18 9:54 ` [PATCH 1/7] phy: fix of_mdio_find_bus() device refcount leak Russell King
2015-09-21 19:01 ` David Miller
2015-09-21 19:32 ` Russell King - ARM Linux [this message]
2015-09-21 22:08 ` David Miller
2015-09-18 9:55 ` [PATCH 2/7] phy: fix mdiobus module safety Russell King
2015-09-18 9:55 ` [PATCH 3/7] phy: add proper phy struct device refcounting Russell King
2015-09-18 9:55 ` [PATCH 4/7] of_mdio: fix MDIO phy " Russell King
2015-09-18 9:55 ` [PATCH 5/7] net: fix phy refcounting in a bunch of drivers Russell King
2015-09-18 9:55 ` [PATCH 6/7] phy: fixed-phy: properly validate phy in fixed_phy_update_state() Russell King
2015-09-18 9:55 ` [PATCH 7/7] phy: add phy_device_remove() Russell King
2015-09-18 9:56 ` [PATCH 0/7] Phy and mdiobus fixes Russell King - ARM Linux
2015-09-18 15:01 ` Sören Brinkmann
2015-09-18 15:20 ` Russell King - ARM Linux
2015-09-19 20:49 ` Florian Fainelli
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=20150921193206.GU21084@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=frowand.list@gmail.com \
--cc=grant.likely@linaro.org \
--cc=isubramanian@apm.com \
--cc=kchudgar@apm.com \
--cc=leoli@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=michal.simek@xilinx.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=rric@kernel.org \
--cc=sgoutham@cavium.com \
--cc=soren.brinkmann@xilinx.com \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).