From: Greg KH <gregkh@suse.de>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-kernel@vger.kernel.org, dm-devel@redhat.com
Subject: Re: kobject_put vs module unload
Date: Fri, 7 Jan 2011 21:56:21 -0800 [thread overview]
Message-ID: <20110108055621.GB10391@suse.de> (raw)
In-Reply-To: <Pine.LNX.4.64.1101072234040.382@hs20-bc2-1.build.redhat.com>
On Fri, Jan 07, 2011 at 10:42:22PM -0500, Mikulas Patocka wrote:
> Hi
>
> I'm looking at some kobject problem in device mapper and I came across
> this problem:
>
> According to kobject interface specification, If we embed a kobject into
> the device structure, we shouldn't free the device structure when the
> device is unloaded, but we should register a "release" callback in
> kobj_type that will actually free the device structure.
That is correct.
What does "device is unloaded" mean? That really doesn't mean anything
in reference to the driver model/kobject code.
> What happens in this scenario?:
>
> 1) someone references a device kobject
> 2) the device is unloaded (but the device structure is still in memory
> because of that reference)
What do you mean here? How can a device be "unloaded"? Is it just
unregistered?
> 3) the driver module is unloaded
Oops, you just lost.
> 4) the reference obtained at point 1) is dropped, kobject reference count
> reaches zero and the release callback is called. But that callback points
> to an unloaded module and causes a crash.
>
> How is it solved? Am I missing something?
You have the code that creates and frees the object, to not be in the
module that could have been unloaded. It's really just that simple.
Hope this helps,
greg k-h
next prev parent reply other threads:[~2011-01-08 5:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-08 3:42 kobject_put vs module unload Mikulas Patocka
2011-01-08 5:56 ` Greg KH [this message]
2011-01-08 13:19 ` Mikulas Patocka
2011-01-08 17:23 ` Kay Sievers
2011-01-08 18:01 ` Mikulas Patocka
2011-01-08 18:09 ` Kay Sievers
2011-01-08 18:50 ` Mikulas Patocka
2011-01-08 23:49 ` Greg KH
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=20110108055621.GB10391@suse.de \
--to=gregkh@suse.de \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.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