aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-08-16 08:30:30 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-08-21 13:15:38 -0400
commit5c0ef6d0214a08e5c846f4c45228adf135d8d0ef (patch)
treef4c5d5991365e19780e3638eb2128c8ebd771e99 /block/genhd.c
parent068281d302def5efd96d84a163ba17e85f5ea564 (diff)
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/genhd.c')
-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)
313 313
314 mutex_lock(&block_class_lock); 314 mutex_lock(&block_class_lock);
315 dev = class_find_device(&block_class, NULL, &k, find_start); 315 dev = class_find_device(&block_class, NULL, &k, find_start);
316 if (dev) 316 if (dev) {
317 put_device(dev);
317 return dev_to_disk(dev); 318 return dev_to_disk(dev);
319 }
318 return NULL; 320 return NULL;
319} 321}
320 322
@@ -331,8 +333,10 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
331 struct device *dev; 333 struct device *dev;
332 ++*pos; 334 ++*pos;
333 dev = class_find_device(&block_class, &gp->dev, NULL, find_next); 335 dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
334 if (dev) 336 if (dev) {
337 put_device(dev);
335 return dev_to_disk(dev); 338 return dev_to_disk(dev);
339 }
336 return NULL; 340 return NULL;
337} 341}
338 342
@@ -573,8 +577,10 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
573 577
574 mutex_lock(&block_class_lock); 578 mutex_lock(&block_class_lock);
575 dev = class_find_device(&block_class, NULL, &k, find_start); 579 dev = class_find_device(&block_class, NULL, &k, find_start);
576 if (dev) 580 if (dev) {
581 put_device(dev);
577 return dev_to_disk(dev); 582 return dev_to_disk(dev);
583 }
578 return NULL; 584 return NULL;
579} 585}
580 586
@@ -585,8 +591,10 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
585 591
586 ++*pos; 592 ++*pos;
587 dev = class_find_device(&block_class, &gp->dev, NULL, find_next); 593 dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
588 if (dev) 594 if (dev) {
595 put_device(dev);
589 return dev_to_disk(dev); 596 return dev_to_disk(dev);
597 }
590 return NULL; 598 return NULL;
591} 599}
592 600
@@ -714,10 +722,12 @@ dev_t blk_lookup_devt(const char *name, int part)
714 mutex_lock(&block_class_lock); 722 mutex_lock(&block_class_lock);
715 find.name = name; 723 find.name = name;
716 find.part = part; 724 find.part = part;
717 dev = class_find_device(&block_class, NULL, (void *)&find, match_id); 725 dev = class_find_device(&block_class, NULL, &find, match_id);
718 if (dev) 726 if (dev) {
727 put_device(dev);
719 devt = MKDEV(MAJOR(dev->devt), 728 devt = MKDEV(MAJOR(dev->devt),
720 MINOR(dev->devt) + part); 729 MINOR(dev->devt) + part);
730 }
721 mutex_unlock(&block_class_lock); 731 mutex_unlock(&block_class_lock);
722 732
723 return devt; 733 return devt;