summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-10-11 15:20:49 -0400
committerJens Axboe <axboe@kernel.dk>2018-10-16 11:50:03 -0400
commit71327f547ee3a46ec5c39fdbbd268401b2578d0e (patch)
tree6c887980b26407e736d4275da318affba46ff372 /drivers/block
parent3e6b8c3c4b14f4f0c4a74027156eb31544c0b0da (diff)
ataflop: fix error handling during setup
Move queue allocation next to disk allocation to fix a couple of issues: - If add_disk() hasn't been called, we should clear disk->queue before calling put_disk(). - If we fail to allocate a request queue, we still need to put all of the disks, not just the ones that we allocated queues for. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/ataflop.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 17df631c5d85..0144d598ac47 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -2014,6 +2014,11 @@ static int __init atari_floppy_init (void)
2014 unit[i].disk = alloc_disk(1); 2014 unit[i].disk = alloc_disk(1);
2015 if (!unit[i].disk) 2015 if (!unit[i].disk)
2016 goto Enomem; 2016 goto Enomem;
2017
2018 unit[i].disk->queue = blk_init_queue(do_fd_request,
2019 &ataflop_lock);
2020 if (!unit[i].disk->queue)
2021 goto Enomem;
2017 } 2022 }
2018 2023
2019 if (UseTrackbuffer < 0) 2024 if (UseTrackbuffer < 0)
@@ -2045,10 +2050,6 @@ static int __init atari_floppy_init (void)
2045 sprintf(unit[i].disk->disk_name, "fd%d", i); 2050 sprintf(unit[i].disk->disk_name, "fd%d", i);
2046 unit[i].disk->fops = &floppy_fops; 2051 unit[i].disk->fops = &floppy_fops;
2047 unit[i].disk->private_data = &unit[i]; 2052 unit[i].disk->private_data = &unit[i];
2048 unit[i].disk->queue = blk_init_queue(do_fd_request,
2049 &ataflop_lock);
2050 if (!unit[i].disk->queue)
2051 goto Enomem;
2052 set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); 2053 set_capacity(unit[i].disk, MAX_DISK_SIZE * 2);
2053 add_disk(unit[i].disk); 2054 add_disk(unit[i].disk);
2054 } 2055 }
@@ -2063,13 +2064,17 @@ static int __init atari_floppy_init (void)
2063 2064
2064 return 0; 2065 return 0;
2065Enomem: 2066Enomem:
2066 while (i--) { 2067 do {
2067 struct request_queue *q = unit[i].disk->queue; 2068 struct gendisk *disk = unit[i].disk;
2068 2069
2069 put_disk(unit[i].disk); 2070 if (disk) {
2070 if (q) 2071 if (disk->queue) {
2071 blk_cleanup_queue(q); 2072 blk_cleanup_queue(disk->queue);
2072 } 2073 disk->queue = NULL;
2074 }
2075 put_disk(unit[i].disk);
2076 }
2077 } while (i--);
2073 2078
2074 unregister_blkdev(FLOPPY_MAJOR, "fd"); 2079 unregister_blkdev(FLOPPY_MAJOR, "fd");
2075 return -ENOMEM; 2080 return -ENOMEM;