mirror of
https://github.com/joel16/android_kernel_sony_msm8994.git
synced 2024-11-23 20:20:21 +00:00
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>
This commit is contained in:
parent
068281d302
commit
5c0ef6d021
@ -313,8 +313,10 @@ static void *part_start(struct seq_file *part, loff_t *pos)
|
|||||||
|
|
||||||
mutex_lock(&block_class_lock);
|
mutex_lock(&block_class_lock);
|
||||||
dev = class_find_device(&block_class, NULL, &k, find_start);
|
dev = class_find_device(&block_class, NULL, &k, find_start);
|
||||||
if (dev)
|
if (dev) {
|
||||||
|
put_device(dev);
|
||||||
return dev_to_disk(dev);
|
return dev_to_disk(dev);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,8 +333,10 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
|
|||||||
struct device *dev;
|
struct device *dev;
|
||||||
++*pos;
|
++*pos;
|
||||||
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
||||||
if (dev)
|
if (dev) {
|
||||||
|
put_device(dev);
|
||||||
return dev_to_disk(dev);
|
return dev_to_disk(dev);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,8 +577,10 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos)
|
|||||||
|
|
||||||
mutex_lock(&block_class_lock);
|
mutex_lock(&block_class_lock);
|
||||||
dev = class_find_device(&block_class, NULL, &k, find_start);
|
dev = class_find_device(&block_class, NULL, &k, find_start);
|
||||||
if (dev)
|
if (dev) {
|
||||||
|
put_device(dev);
|
||||||
return dev_to_disk(dev);
|
return dev_to_disk(dev);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,8 +591,10 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
|
|||||||
|
|
||||||
++*pos;
|
++*pos;
|
||||||
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
|
||||||
if (dev)
|
if (dev) {
|
||||||
|
put_device(dev);
|
||||||
return dev_to_disk(dev);
|
return dev_to_disk(dev);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,10 +722,12 @@ dev_t blk_lookup_devt(const char *name, int part)
|
|||||||
mutex_lock(&block_class_lock);
|
mutex_lock(&block_class_lock);
|
||||||
find.name = name;
|
find.name = name;
|
||||||
find.part = part;
|
find.part = part;
|
||||||
dev = class_find_device(&block_class, NULL, (void *)&find, match_id);
|
dev = class_find_device(&block_class, NULL, &find, match_id);
|
||||||
if (dev)
|
if (dev) {
|
||||||
|
put_device(dev);
|
||||||
devt = MKDEV(MAJOR(dev->devt),
|
devt = MKDEV(MAJOR(dev->devt),
|
||||||
MINOR(dev->devt) + part);
|
MINOR(dev->devt) + part);
|
||||||
|
}
|
||||||
mutex_unlock(&block_class_lock);
|
mutex_unlock(&block_class_lock);
|
||||||
|
|
||||||
return devt;
|
return devt;
|
||||||
|
Loading…
Reference in New Issue
Block a user