public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Chris Rankin <rankincj@yahoo.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Greg K-H <greg@kroah.com>
Subject: Re: [linux-usb-devel] Bug creating USB endpoints in 2.6.20.x (kernel bug 8198)
Date: Wed, 09 May 2007 11:40:33 +0200	[thread overview]
Message-ID: <46419711.8050003@gmail.com> (raw)
In-Reply-To: <963898.10047.qm@web52906.mail.re2.yahoo.com>

[adding back linux-usb-devel.  please don't drop cc]
[also adding lkml and Greg K-H]

Chris Rankin wrote:
> --- Tejun Heo <htejun@gmail.com> wrote:
>> Okay, here's patch against 2.6.20.11.  Let's hope we're not chasing
>> something which is already fixed.
> 
> Hooray! The trick was to trace the "dev" file instead of the endpoint directory itself. The
> compressed oops is attached.

Alright, it took a lot of work but the winner is the "dev" node.  Gee...
We could have caught this earlier unless I forgot to print the name of
the last component in the initial debug patch.  Well, better late than
never.  :-(

Anyways, the problem is that the attribute "dev" is dynamically
allocated using kmalloc() in device_add() and freed immediately after
the file is removed in device_del().  It's basically assuming
immediate-disconnect but that apparently isn't true yet.

The dynamic allocation is to set the owner of the attribute to the owner
of the device being registered.  This is twisted in that the field is
added to work around sysfs/module lifetime problem but the workaround
itself is broken with regard to lifetime rules.  Aieeeeeeee...  This
sort of things are why I implemented immediate disconnect on sysfs in
the first place.

So, we can fix the problem Chris is seeing by breaking module unload (by
allowing it to unload too early).  It doesn't sound too hot but module
unloading race is much less likely than sysfs node deletion/open race.

Thanks.

-- 
tejun

       reply	other threads:[~2007-05-09  9:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <963898.10047.qm@web52906.mail.re2.yahoo.com>
2007-05-09  9:40 ` Tejun Heo [this message]
2007-05-09 12:24   ` [linux-usb-devel] Bug creating USB endpoints in 2.6.20.x (kernel bug 8198) Chris Rankin
2007-05-09 13:30     ` Tejun Heo
2007-05-09 13:56       ` Chris Rankin
2007-05-09 14:11         ` Tejun Heo
2007-05-09 14:35           ` Dmitry Torokhov
2007-05-09 14:58             ` Tejun Heo
2007-05-09 21:09               ` Chris Rankin
2007-05-09 14:57       ` Greg KH
2007-05-09 15:01         ` Tejun Heo
2007-05-09 15:40           ` Greg KH
2007-05-10 14:45             ` [PATCH] driver-core: don't free devt_attr till the device is released Tejun Heo
2007-05-10 15:05               ` Greg KH
2007-05-10 15:13                 ` Tejun Heo
2007-05-10 15:17                   ` Greg KH
2007-05-10 15:33               ` Kay Sievers
2007-05-10 15:41                 ` Tejun Heo
2007-05-10 15:52               ` Alan Stern
2007-05-10 16:18                 ` Tejun Heo
2007-05-10 14:25         ` [PATCH 2.6.21-mm2] driver-core: make devt_attr and uevent_attr static Tejun Heo

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=46419711.8050003@gmail.com \
    --to=htejun@gmail.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=rankincj@yahoo.com \
    --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