mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.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: Thu, 5 Jan 2012 15:17:31 -0800	[thread overview]
Message-ID: <20120105231731.GA15539@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1201051531410.1434-100000@iolanthe.rowland.org>

On Thu, Jan 05, 2012 at 03:48:19PM -0500, Alan Stern wrote:
> On Thu, 5 Jan 2012, Dmitry Torokhov wrote:
> 
> > So I looked at the users of device_attach():
> > 
> > - we call it from generic bus code when adding a new driver so naturally
> >   driver is valid there;
> > - serio and gameport call it by hand but they ensure that the driver is
> >   valid because they protected by subsystem-private mutex;
> > - PCI, PCMCI, HID and USB new_id handling is tied to the driver itself
> >   and attributes are removed when driver is unregistered so there is no
> >   chance driver will be attached through newid after it has been
> >   unregistered;
> > - agp_amd64_init calls it once immediately after registering the driver;
> > - pci-stub driver is safe as well.
> 
> Okay, that's all good.
> 
> > That leaves only usb-serial which is problematic exactly as you
> > described below. So I think we should remove get_driver() and
> > put_driver(); document that caller if driver_attach() should ensure
> > that driver is live and let usb-serial code solve this issue as this
> > is the only code that plays games with drivers it does not own.
> 
> If Greg confirms that there's nothing with registering the usb driver 
> before the usb_serial driver, I can fix the usb-serial code easily.
> 
> Greg, do you know offhand whether this will break anything?  It really 
> seems like the right thing to do, because the usb_serial driver uses 
> the usb driver but not vice versa.

Hm, there was a reason I ordered the way I did, as I remember having to
go fix up a number of drivers that did it in the reverse order.  Give me
a day or so to dig it up and figure out what is going on here, and to
review this thread.

thanks,

greg k-h

  reply	other threads:[~2012-01-05 23:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-05 16:31 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 [this message]
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
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=20120105231731.GA15539@kroah.com \
    --to=greg@kroah.com \
    --cc=dmitry.torokhov@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome