1 |
From 32651ac85ee56a26fbbc1ec80c97eb42f7fe3172 Mon Sep 17 00:00:00 2001 |
2 |
From: Omar Sandoval <osandov@fb.com> |
3 |
Date: Thu, 11 Oct 2018 12:20:41 -0700 |
4 |
Subject: [PATCH 007/145] swim: fix cleanup on setup error |
5 |
|
6 |
[ Upstream commit 1448a2a5360ae06f25e2edc61ae070dff5c0beb4 ] |
7 |
|
8 |
If we fail to allocate the request queue for a disk, we still need to |
9 |
free that disk, not just the previous ones. Additionally, we need to |
10 |
cleanup the previous request queues. |
11 |
|
12 |
Signed-off-by: Omar Sandoval <osandov@fb.com> |
13 |
Signed-off-by: Jens Axboe <axboe@kernel.dk> |
14 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
15 |
--- |
16 |
drivers/block/swim.c | 13 +++++++++++-- |
17 |
1 file changed, 11 insertions(+), 2 deletions(-) |
18 |
|
19 |
diff --git a/drivers/block/swim.c b/drivers/block/swim.c |
20 |
index 0e31884a9519..cbe909c51847 100644 |
21 |
--- a/drivers/block/swim.c |
22 |
+++ b/drivers/block/swim.c |
23 |
@@ -887,8 +887,17 @@ static int swim_floppy_init(struct swim_priv *swd) |
24 |
|
25 |
exit_put_disks: |
26 |
unregister_blkdev(FLOPPY_MAJOR, "fd"); |
27 |
- while (drive--) |
28 |
- put_disk(swd->unit[drive].disk); |
29 |
+ do { |
30 |
+ struct gendisk *disk = swd->unit[drive].disk; |
31 |
+ |
32 |
+ if (disk) { |
33 |
+ if (disk->queue) { |
34 |
+ blk_cleanup_queue(disk->queue); |
35 |
+ disk->queue = NULL; |
36 |
+ } |
37 |
+ put_disk(disk); |
38 |
+ } |
39 |
+ } while (drive--); |
40 |
return err; |
41 |
} |
42 |
|
43 |
-- |
44 |
2.19.1 |
45 |
|