aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-03-18 10:08:43 -0400
committerJens Axboe <axboe@kernel.dk>2019-03-18 10:08:43 -0400
commit6ce59025f1182125e75c8d121daf44056b65dd1f (patch)
tree05822c7af83a5e388722c9d448ba303285b3927e
parent9e98c678c2d6ae3a17cb2de55d17f69dddaa231b (diff)
paride/pf: cleanup queues when detection fails
The driver allocates queues for all the units it potentially supports. But if we fail to detect any drives, then we fail loading the module without cleaning up those queues. This is now evident with the switch to blk-mq, though the bug has been there forever as far as I can tell. Also fix cleanup through regular module exit. Reported-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--drivers/block/paride/pf.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index e92e7a8eeeb2..103b617cdc31 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -761,8 +761,12 @@ static int pf_detect(void)
761 return 0; 761 return 0;
762 762
763 printk("%s: No ATAPI disk detected\n", name); 763 printk("%s: No ATAPI disk detected\n", name);
764 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 764 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
765 blk_cleanup_queue(pf->disk->queue);
766 pf->disk->queue = NULL;
767 blk_mq_free_tag_set(&pf->tag_set);
765 put_disk(pf->disk); 768 put_disk(pf->disk);
769 }
766 pi_unregister_driver(par_drv); 770 pi_unregister_driver(par_drv);
767 return -1; 771 return -1;
768} 772}
@@ -1047,13 +1051,15 @@ static void __exit pf_exit(void)
1047 int unit; 1051 int unit;
1048 unregister_blkdev(major, name); 1052 unregister_blkdev(major, name);
1049 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { 1053 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
1050 if (!pf->present) 1054 if (pf->present)
1051 continue; 1055 del_gendisk(pf->disk);
1052 del_gendisk(pf->disk); 1056
1053 blk_cleanup_queue(pf->disk->queue); 1057 blk_cleanup_queue(pf->disk->queue);
1054 blk_mq_free_tag_set(&pf->tag_set); 1058 blk_mq_free_tag_set(&pf->tag_set);
1055 put_disk(pf->disk); 1059 put_disk(pf->disk);
1056 pi_release(pf->pi); 1060
1061 if (pf->present)
1062 pi_release(pf->pi);
1057 } 1063 }
1058} 1064}
1059 1065