Commit 63d94e48 authored by Jun'ichi Nomura's avatar Jun'ichi Nomura Committed by Linus Torvalds

[PATCH] dm: free minor after unlink gendisk

Minor number should be freed after del_gendisk().  Otherwise, there could
be a window where 2 registered gendisk has same minor number.
Signed-off-by: default avatarJun'ichi Nomura <j-nomura@ce.jp.nec.com>
Acked-by: default avatarAlasdair G Kergon <agk@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent d9dde59b
...@@ -849,14 +849,16 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent) ...@@ -849,14 +849,16 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
static void free_dev(struct mapped_device *md) static void free_dev(struct mapped_device *md)
{ {
unsigned int minor = md->disk->first_minor;
if (md->suspended_bdev) { if (md->suspended_bdev) {
thaw_bdev(md->suspended_bdev, NULL); thaw_bdev(md->suspended_bdev, NULL);
bdput(md->suspended_bdev); bdput(md->suspended_bdev);
} }
free_minor(md->disk->first_minor);
mempool_destroy(md->tio_pool); mempool_destroy(md->tio_pool);
mempool_destroy(md->io_pool); mempool_destroy(md->io_pool);
del_gendisk(md->disk); del_gendisk(md->disk);
free_minor(minor);
put_disk(md->disk); put_disk(md->disk);
blk_put_queue(md->queue); blk_put_queue(md->queue);
kfree(md); kfree(md);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment