Skip to contentSkip to conversation

block: missing module_put in put_disk

PATCH In review Chun Wu 2 participants 2 messages Oct 29, 2010 Block layer

lore
Share & tools
lore

Chun Wu

author
#0 lore raw

PATCH 1/1 block: missing module_put in put_disk

From: Chun Wu <[email protected]>

module_put function is not called in put_disk function. Should it be added?

---
 block/genhd.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
block/genhd.c +7 -0
index 5fa2b44..91299dc 100644
@@ -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);
 }
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 3 lines · Chun Wu

From: Chun Wu <[email protected]>

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]