aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>2012-08-27 19:56:51 -0400
committerJens Axboe <axboe@kernel.dk>2012-10-30 03:34:24 -0400
commitb54e1f88897bcacc2cd359f48ea3b39eaf55f084 (patch)
tree664c10b93917479b78e11d8e53d77f7a5e9cc440 /drivers/block
parent2911758f14e36a7cd5c7367f951dcb8817552f71 (diff)
floppy: don't call alloc_ordered_workqueue inside the alloc_disk loop
Since commit 070ad7e ("floppy: convert to delayed work and single-thread wq"), we end up calling alloc_ordered_workqueue multiple times inside the loop, which shouldn't be intended. Besides the leak, other side effect in the current code is if blk_init_queue fails, we would end up calling unregister_blkdev even if we didn't call yet register_blkdev. Just moved the allocation of floppy_wq before the loop, and adjusted the code accordingly. Cc: stable@vger.kernel.org # 3.5+ Acked-by: Vivek Goyal <vgoyal@redhat.com> Reviewed-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/floppy.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 17c675c52295..83112f08a41d 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4137,6 +4137,10 @@ static int __init do_floppy_init(void)
4137 4137
4138 raw_cmd = NULL; 4138 raw_cmd = NULL;
4139 4139
4140 floppy_wq = alloc_ordered_workqueue("floppy", 0);
4141 if (!floppy_wq)
4142 return -ENOMEM;
4143
4140 for (dr = 0; dr < N_DRIVE; dr++) { 4144 for (dr = 0; dr < N_DRIVE; dr++) {
4141 disks[dr] = alloc_disk(1); 4145 disks[dr] = alloc_disk(1);
4142 if (!disks[dr]) { 4146 if (!disks[dr]) {
@@ -4144,16 +4148,10 @@ static int __init do_floppy_init(void)
4144 goto out_put_disk; 4148 goto out_put_disk;
4145 } 4149 }
4146 4150
4147 floppy_wq = alloc_ordered_workqueue("floppy", 0);
4148 if (!floppy_wq) {
4149 err = -ENOMEM;
4150 goto out_put_disk;
4151 }
4152
4153 disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock); 4151 disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock);
4154 if (!disks[dr]->queue) { 4152 if (!disks[dr]->queue) {
4155 err = -ENOMEM; 4153 err = -ENOMEM;
4156 goto out_destroy_workq; 4154 goto out_put_disk;
4157 } 4155 }
4158 4156
4159 blk_queue_max_hw_sectors(disks[dr]->queue, 64); 4157 blk_queue_max_hw_sectors(disks[dr]->queue, 64);
@@ -4317,8 +4315,6 @@ out_release_dma:
4317out_unreg_region: 4315out_unreg_region:
4318 blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); 4316 blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
4319 platform_driver_unregister(&floppy_driver); 4317 platform_driver_unregister(&floppy_driver);
4320out_destroy_workq:
4321 destroy_workqueue(floppy_wq);
4322out_unreg_blkdev: 4318out_unreg_blkdev:
4323 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4319 unregister_blkdev(FLOPPY_MAJOR, "fd");
4324out_put_disk: 4320out_put_disk:
@@ -4334,6 +4330,7 @@ out_put_disk:
4334 } 4330 }
4335 put_disk(disks[dr]); 4331 put_disk(disks[dr]);
4336 } 4332 }
4333 destroy_workqueue(floppy_wq);
4337 return err; 4334 return err;
4338} 4335}
4339 4336