[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGVrzcZOE8BFEM+7b_6tygi0FTRneEr2bGiRHW_+7bk3fqF1Fg@mail.gmail.com>
Date: Wed, 23 Jul 2014 11:46:35 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>
Cc: netdev <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>,
Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>,
Gregory Clement <gregory.clement@...e-electrons.com>
Subject: Re: [PATCH 2/2] net: phy: Ensure the MDIO bus module is held
2014-07-23 11:40 GMT-07:00 Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>:
> On 23 Jul 11:22 AM, Florian Fainelli wrote:
>> 2014-07-22 17:16 GMT-07:00 Ezequiel Garcia <ezequiel.garcia@...e-electrons.com>:
>> > @@ -614,10 +623,14 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>> > */
>> > err = phy_init_hw(phydev);
>> > if (err)
>> > - phy_detach(phydev);
>> > - else
>> > - phy_resume(phydev);
>> > + goto err_module_put;
>> >
>> > + phy_resume(phydev);
>> > + return err;
>> > +
>> > +err_module_put:
>> > + module_put(bus_module);
>> > + phy_detach(phydev);
>>
>> Since we are calling phy_detach() which is also attempting to do a
>> module_put(), does not that result in one too many calls to
>> module_put() on error path?
>>
>
> As far as I can see all that module_get() and module_put() do
> is increment and decrement refcounters. Therefore, I think you can
> have as many module_{get,put}() calls as you want on a path.
Ok, I was concerned that in case that specific PHY device cannot be
registered, we might be decrementing the reference count twice, hence
making it 0. There might be another PHY device sitting on this same
MDIO bus, and since the reference count for the MDIO driver is now 0,
we could end up unloading that module.
Exercising that specific case is not probably easy to trigger.
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists