public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: missing module_put in put_disk
@ 2010-10-29 15:51 Chun Wu
  2010-10-29 16:09 ` Al Viro
  0 siblings, 1 reply; 2+ messages in thread
From: Chun Wu @ 2010-10-29 15:51 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel, Chun Wu

From: Chun Wu <chun.wu84@gmail.com>

module_put function is not called in put_disk function. Should it be added?
 
Signed-off-by: Chun Wu <chun.wu84@gmail.com>
---
 block/genhd.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 5fa2b44..91299dc 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1228,6 +1228,13 @@ EXPORT_SYMBOL(get_disk);
 
 void put_disk(struct gendisk *disk)
 {
+#ifdef CONFIG_MODULE_UNLOAD
+	struct module *owner;
+
+	owner = disk->fops->owner;
+	if (owner)
+		module_put(owner);
+#endif
 	if (disk)
 		kobject_put(&disk_to_dev(disk)->kobj);
 }
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: missing module_put in put_disk
  2010-10-29 15:51 [PATCH] block: missing module_put in put_disk Chun Wu
@ 2010-10-29 16:09 ` Al Viro
  0 siblings, 0 replies; 2+ messages in thread
From: Al Viro @ 2010-10-29 16:09 UTC (permalink / raw)
  To: Chun Wu; +Cc: axboe, linux-kernel

On Fri, Oct 29, 2010 at 11:51:35AM -0400, Chun Wu wrote:
> From: Chun Wu <chun.wu84@gmail.com>
> 
> module_put function is not called in put_disk function. Should it be added?

Check the callers.  Check the callers of get_disk.  Think whether those
two are counterparts.  See if any callers would have module_put() nearby.
See if any callers would not have module_put() nearby.  See if there is
anything that would distinguish one class from another.  Think whether
they need different behaviour.  Then you'll be able to answer your
question.  As a bonus, consider the source of confusion and see if you
can remove it [I'm serious, BTW - get_disk() is apparently a lousy name
asking for confusion; renaming it might be a useful thing to do, provided
that new name would be less confusing]

[snip the patch blindly adding such call]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-29 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-29 15:51 [PATCH] block: missing module_put in put_disk Chun Wu
2010-10-29 16:09 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox