public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Gregory Clement <gregory.clement@free-electrons.com>
Subject: Re: [PATCH 2/2] net: phy: Ensure the MDIO bus module is held
Date: Wed, 23 Jul 2014 15:54:14 -0300	[thread overview]
Message-ID: <20140723185414.GA23100@arch.cereza> (raw)
In-Reply-To: <20140723184041.GA24850@arch.cereza>

On 23 Jul 03:40 PM, Ezequiel Garcia wrote:
> On 23 Jul 11:22 AM, Florian Fainelli wrote:
> > 2014-07-22 17:16 GMT-07:00 Ezequiel Garcia <ezequiel.garcia@free-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.

After reading this again, I know see what your pointing. The call to
phy_detach already puts the module, so we don't need to do it on the
error path above.

I'll cook up v2.
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

      parent reply	other threads:[~2014-07-23 18:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23  0:16 [PATCH 0/2] net: phy: Prevent an MDIO bus from being unloaded while in use Ezequiel Garcia
2014-07-23  0:16 ` [PATCH 1/2] net: phy: Set the driver when registering an MDIO bus device Ezequiel Garcia
2014-07-23 18:26   ` Florian Fainelli
2014-07-23  0:16 ` [PATCH 2/2] net: phy: Ensure the MDIO bus module is held Ezequiel Garcia
2014-07-23 18:22   ` Florian Fainelli
2014-07-23 18:40     ` Ezequiel Garcia
2014-07-23 18:46       ` Florian Fainelli
2014-07-23 18:54       ` Ezequiel Garcia [this message]

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=20140723185414.GA23100@arch.cereza \
    --to=ezequiel.garcia@free-electrons.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=netdev@vger.kernel.org \
    --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