Skip to content

Commit 6ce5902

Browse files
committed
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>
1 parent 9e98c67 commit 6ce5902

File tree

1 file changed

+11
-5
lines changed
  • drivers/block/paride

1 file changed

+11
-5
lines changed

drivers/block/paride/pf.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,12 @@ static int pf_detect(void)
761761
return 0;
762762

763763
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);
765768
put_disk(pf->disk);
769+
}
766770
pi_unregister_driver(par_drv);
767771
return -1;
768772
}
@@ -1047,13 +1051,15 @@ static void __exit pf_exit(void)
10471051
int unit;
10481052
unregister_blkdev(major, name);
10491053
for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
1050-
if (!pf->present)
1051-
continue;
1052-
del_gendisk(pf->disk);
1054+
if (pf->present)
1055+
del_gendisk(pf->disk);
1056+
10531057
blk_cleanup_queue(pf->disk->queue);
10541058
blk_mq_free_tag_set(&pf->tag_set);
10551059
put_disk(pf->disk);
1056-
pi_release(pf->pi);
1060+
1061+
if (pf->present)
1062+
pi_release(pf->pi);
10571063
}
10581064
}
10591065

0 commit comments

Comments
 (0)