summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-08-16 14:30:30 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2008-08-21 10:15:38 -0700
commit5c0ef6d0214a08e5c846f4c45228adf135d8d0ef (patch)
treef4c5d5991365e19780e3638eb2128c8ebd771e99 /block
parent068281d302def5efd96d84a163ba17e85f5ea564 (diff)
downloadlinux-5c0ef6d0214a08e5c846f4c45228adf135d8d0ef.tar.bz2
block: drop references taken by class_find_device()
Otherwise we leak references, which is not a good thing to do. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/block/genhd.c b/block/genhd.c
index f34befc54847..656c2c7abf99 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -313,8 +313,10 @@ static void *part_start(struct seq_file *part, loff_t *pos)
mutex_lock(&block_class_lock);
dev = class_find_device(&block_class, NULL, &k, find_start);
- if (dev)
+ if (dev) {
+ put_device(dev);
return dev_to_disk(dev);
+ }
return NULL;
}
@@ -331,8 +333,10 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
struct device *dev;
++*pos;
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
- if (dev)
+ if (dev) {
+ put_device(dev);
return dev_to_disk(dev);
+ }
return NULL;
}
@@ -573,8 +577,10 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
mutex_lock(&block_class_lock);
dev = class_find_device(&block_class, NULL, &k, find_start);
- if (dev)
+ if (dev) {
+ put_device(dev);
return dev_to_disk(dev);
+ }
return NULL;
}
@@ -585,8 +591,10 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
++*pos;
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
- if (dev)
+ if (dev) {
+ put_device(dev);
return dev_to_disk(dev);
+ }
return NULL;
}
@@ -714,10 +722,12 @@ dev_t blk_lookup_devt(const char *name, int part)
mutex_lock(&block_class_lock);
find.name = name;
find.part = part;
- dev = class_find_device(&block_class, NULL, (void *)&find, match_id);
- if (dev)
+ dev = class_find_device(&block_class, NULL, &find, match_id);
+ if (dev) {
+ put_device(dev);
devt = MKDEV(MAJOR(dev->devt),
MINOR(dev->devt) + part);
+ }
mutex_unlock(&block_class_lock);
return devt;