]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.126/swim-fix-cleanup-on-setup-error.patch
Linux 3.18.140
[thirdparty/kernel/stable-queue.git] / releases / 3.18.126 / swim-fix-cleanup-on-setup-error.patch
1 From foo@baz Sat Nov 10 11:35:27 PST 2018
2 From: Omar Sandoval <osandov@fb.com>
3 Date: Thu, 11 Oct 2018 12:20:41 -0700
4 Subject: swim: fix cleanup on setup error
5
6 From: Omar Sandoval <osandov@fb.com>
7
8 [ Upstream commit 1448a2a5360ae06f25e2edc61ae070dff5c0beb4 ]
9
10 If we fail to allocate the request queue for a disk, we still need to
11 free that disk, not just the previous ones. Additionally, we need to
12 cleanup the previous request queues.
13
14 Signed-off-by: Omar Sandoval <osandov@fb.com>
15 Signed-off-by: Jens Axboe <axboe@kernel.dk>
16 Signed-off-by: Sasha Levin <sashal@kernel.org>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 ---
19 drivers/block/swim.c | 13 +++++++++++--
20 1 file changed, 11 insertions(+), 2 deletions(-)
21
22 --- a/drivers/block/swim.c
23 +++ b/drivers/block/swim.c
24 @@ -868,8 +868,17 @@ static int swim_floppy_init(struct swim_
25
26 exit_put_disks:
27 unregister_blkdev(FLOPPY_MAJOR, "fd");
28 - while (drive--)
29 - put_disk(swd->unit[drive].disk);
30 + do {
31 + struct gendisk *disk = swd->unit[drive].disk;
32 +
33 + if (disk) {
34 + if (disk->queue) {
35 + blk_cleanup_queue(disk->queue);
36 + disk->queue = NULL;
37 + }
38 + put_disk(disk);
39 + }
40 + } while (drive--);
41 return err;
42 }
43