All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <greg@kroah.com>, Kay Sievers <kay.sievers@vrfy.org>,
	USB list <linux-usb@vger.kernel.org>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: Problems with get_driver() and driver_attach() (and new_id too)
Date: Mon, 9 Jan 2012 08:50:53 -0800	[thread overview]
Message-ID: <20120109165053.GA15083@core.coreip.homeip.net> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1201091133400.1541-100000@iolanthe.rowland.org>

On Mon, Jan 09, 2012 at 11:37:57AM -0500, Alan Stern wrote:
> On Mon, 9 Jan 2012, Dmitry Torokhov wrote:
> 
> > > I don't think any of those calls actually accomplish anything, but it's
> > > hard to be certain.  Some of them appear to be futile attempts to
> > > prevent the driver from being unregistered or unloaded, others are
> > > there simply to drop the reference taken by driver_find().
> > > 
> > > In a few of them it's obvious that the driver can't be unregistered 
> > > while the critical section runs, but in the others I can't tell.  On 
> > > the other hand, if a critical section can race with unregistration 
> > > then the code is buggy now.
> > > 
> > > What do you think?
> > 
> > I think we need to audit them and decide on case-by-case basis. For
> > example drivers/s390/cio/device.c is completely nonsensical: it takes a
> > reference on a driver that is passed as argument before calling
> > driver_find_device(). But if passed driver was valid before we called
> > get_driver it won't become any more valid afterwards and it should not
> > disappear either.
> > 
> > drivers/s390/cio/ccwgroup.c - calls are useless;
> > 
> > Authors of drivers/net/phy/phy_device.c had their reservations:
> > 
> >         /* Make sure the driver is held.
> >          * XXX -- Is this correct? */
> >         drv = get_driver(phydev->dev.driver);
> > 
> > However it is in phydev_probe() and I hope our device core takes care of
> > not destroying drivers in the middle of binding to a device.
> 
> Yes, it does.  That one looks like a misunderstanding.  It calls
> get_driver during phy_probe and put_driver during phy_remove, which
> accomplishes nothing.
> 
> > drivers/ssb/main.c seems like needs some protection but does it
> > incorrectly as we do not wait for drivers to drop all references before
> > unloading modules.
> 
> Possibly it needs to be replaced with try_module_get.  I'll send out an 
> email to the maintainers of these drivers to see what they think.

No, I am not that try_module_get() [alone] is quite what is needed, as
strictly speaking driver lifetime does not need to be the same as module
lifetime. But maybe I am just splitting hair as all drivers are
statically initialized and are tied to their modules...

-- 
Dmitry

  reply	other threads:[~2012-01-09 16:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 16:31 Problems with get_driver() and driver_attach() (and new_id too) Alan Stern
2012-01-05 18:01 ` Dmitry Torokhov
2012-01-05 18:55   ` Alan Stern
2012-01-05 20:05     ` Dmitry Torokhov
2012-01-05 20:48       ` Alan Stern
2012-01-05 23:17         ` Greg KH
2012-01-06 14:42           ` Alan Stern
2012-01-06 15:42           ` Alan Stern
2012-01-06 20:29       ` Alan Stern
2012-01-09  8:48         ` Dmitry Torokhov
2012-01-09 16:37           ` Alan Stern
2012-01-09 16:50             ` Dmitry Torokhov [this message]
2012-01-09 17:01               ` Alan Stern
2012-01-09 17:05             ` Dmitry Torokhov
2012-01-09 17:35             ` Incorrect uses of get_driver()/put_driver() Alan Stern
2012-01-09 17:48               ` Konrad Rzeszutek Wilk
2012-01-09 18:20                 ` Dmitry Torokhov
2012-01-09 18:34                   ` Konrad Rzeszutek Wilk
2012-01-09 18:49                     ` Dmitry Torokhov
2012-01-09 19:36                       ` Alan Stern
2012-01-09 18:03               ` Michael Büsch
2012-01-09 18:14                 ` Dmitry Torokhov
2012-01-09 19:48                   ` Alan Stern
2012-01-09 20:07                     ` Michael Büsch
2012-01-09 22:44                       ` Alan Stern
2012-01-09 23:05                         ` Michael Büsch
2012-01-09 18:04               ` Joerg Roedel
2012-01-10  9:05               ` Martin Schwidefsky
2012-01-10  9:20                 ` Dmitry Torokhov
2012-01-10 10:03                   ` Martin Schwidefsky
2012-01-10 10:18                   ` Sebastian Ott
2012-01-10 10:21                 ` Sebastian Ott
2012-01-10 20:32                   ` Alan Stern

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=20120109165053.GA15083@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=greg@kroah.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.