floppy: Fix couple of crashes during init and module removal
Subsystems (2)
cover floppy: Fix couple of crashes during init and module removal
Hi Jens,
Here are couple of fixes for floppy driver. These fixes need to go in for 3.3. Original discussion thread is here.
https://lkml.org/lkml/2012/1/24/138
I am reposting the patches in a separate thread as it might be easier for you to pick up the patches.
Thanks
Vivek
Vivek Goyal (2):
floppy: Cleanup disk->queue before caling put_disk() if add_disk()
was never called
floppy: Fix a crash during rmmod
drivers/block/floppy.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.4.4
PATCH 1/2 floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
add_disk() takes gendisk reference on request queue. If driver failed during initialization and never called add_disk() then that extra reference is not taken. That reference is put in put_disk(). floppy driver allocates the disk, allocates queue, sets disk->queue and then relizes that floppy controller is not present. It tries to tear down everything and tries to put a reference down in put_disk() which was never taken.
In such error cases cleanup disk->queue before calling put_disk() so that we never try to put down a reference which was never taken in first place.
--- drivers/block/floppy.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/block/floppy.c +7 -1
@@ -4368,8 +4368,14 @@ out_unreg_blkdev: out_put_disk:while (dr--) {del_timer_sync (&motor_off_timer[dr]); -if (disks[dr]->queue) +if (disks[dr]->queue) {blk_cleanup_queue (disks[dr]->queue); +/* +* put_disk() is not paired with add_disk() and +* will put queue reference one extra time. fix it. +*/ + disks[dr]->queue =NULL ; + }put_disk (disks[dr]); }return err;
Signature · 1 line
1.7.4.4
PATCH 2/2 floppy: Fix a crash during rmmod
In reply to Vivek Goyalfloppy 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.
--- drivers/block/floppy.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/block/floppy.c +9 -0
@@ -4585,6 +4585,15 @@ static void __exit floppy_module_exit(void)platform_device_unregister (&floppy_device[drive]); }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]); }
Signature · 1 line
1.7.4.4
Quoted 10 lines · Vivek Goyal
Hi Jens,
Here are couple of fixes for floppy driver. These fixes need to go in for 3.3. Original discussion thread is here.
https://lkml.org/lkml/2012/1/24/138
I am reposting the patches in a separate thread as it might be easier for you to pick up the patches.
Hi Jens,
Can you please apply these two floppy driver fixes.
Thanks
Vivek
Quoted 13 lines
Thanks
VivekVivek Goyal (2):
floppy: Cleanupdisk->queuebefore calingput_disk()ifadd_disk()
was never called
floppy: Fix a crash during rmmoddrivers/block/floppy.c | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-)Signature · 1 line
1.7.4.4
Jens Axboe
maintainerQuoted 8 lines · Vivek Goyal
Quoted 7 lines · Vivek Goyal
Hi Jens,
Here are couple of fixes for floppy driver. These fixes need to go in for 3.3. Original discussion thread is here.
Quoted 7 lines
Quoted 3 lines
I am reposting the patches in a separate thread as it might be easier for you to pick up the patches.
Hi Jens,
Can you please apply these two floppy driver fixes.
Yep, thanks, applied.
Signature · 1 line
Jens Axboe