From: Omar Sandoval Date: Thu, 11 Oct 2018 19:20:41 +0000 (-0700) Subject: swim: fix cleanup on setup error X-Git-Tag: v4.9.137~113 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2b544ef5e0fada663a565857d688f7f61b5fa27;p=platform%2Fkernel%2Flinux-amlogic.git swim: fix cleanup on setup error [ Upstream commit 1448a2a5360ae06f25e2edc61ae070dff5c0beb4 ] If we fail to allocate the request queue for a disk, we still need to free that disk, not just the previous ones. Additionally, we need to cleanup the previous request queues. Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/block/swim.c b/drivers/block/swim.c index b5afd49..eec6e39 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -868,8 +868,17 @@ static int swim_floppy_init(struct swim_priv *swd) exit_put_disks: unregister_blkdev(FLOPPY_MAJOR, "fd"); - while (drive--) - put_disk(swd->unit[drive].disk); + do { + struct gendisk *disk = swd->unit[drive].disk; + + if (disk) { + if (disk->queue) { + blk_cleanup_queue(disk->queue); + disk->queue = NULL; + } + put_disk(disk); + } + } while (drive--); return err; }