Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4609dff6 authored by Vivek Goyal's avatar Vivek Goyal Committed by Jens Axboe
Browse files

floppy: Fix a crash during rmmod



floppy driver does not call add_disk() on all the drives hence we don't take
gendisk reference on request queue for these drives. Don't call put_disk()
with disk->queue set, otherwise we try to put the reference we never took.

Reported-and-tested-by: default avatarDirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de>
Signed-off-by: default avatarVivek <Goyal&lt;vgoyal@redhat.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3f9a5aab
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -4585,6 +4585,15 @@ static void __exit floppy_module_exit(void)
			platform_device_unregister(&floppy_device[drive]);
			platform_device_unregister(&floppy_device[drive]);
		}
		}
		blk_cleanup_queue(disks[drive]->queue);
		blk_cleanup_queue(disks[drive]->queue);

		/*
		 * These disks have not called add_disk().  Don't put down
		 * queue reference in put_disk().
		 */
		if (!(allowed_drive_mask & (1 << drive)) ||
		    fdc_state[FDC(drive)].version == FDC_NONE)
			disks[drive]->queue = NULL;

		put_disk(disks[drive]);
		put_disk(disks[drive]);
	}
	}