Skip to content

Commit d0ea4c6

Browse files
robnbehlendorf
authored andcommitted
linux/zvol_os: don't try to set disk ops if alloc fails
If the kernel fails to allocate the gendisk, zvo_disk will be NULL, and derefencing it will explode. So don't do that. Sponsored-by: Klara, Inc. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes openzfs#17396
1 parent 023a432 commit d0ea4c6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

module/os/linux/zfs/zvol_os.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,13 +1395,15 @@ zvol_alloc(dev_t dev, const char *name, uint64_t volblocksize)
13951395
*/
13961396
if (zv->zv_zso->use_blk_mq) {
13971397
ret = zvol_alloc_blk_mq(zv, &limits);
1398+
if (ret != 0)
1399+
goto out_kmem;
13981400
zso->zvo_disk->fops = &zvol_ops_blk_mq;
13991401
} else {
14001402
ret = zvol_alloc_non_blk_mq(zso, &limits);
1403+
if (ret != 0)
1404+
goto out_kmem;
14011405
zso->zvo_disk->fops = &zvol_ops;
14021406
}
1403-
if (ret != 0)
1404-
goto out_kmem;
14051407

14061408
/* Limit read-ahead to a single page to prevent over-prefetching. */
14071409
blk_queue_set_read_ahead(zso->zvo_queue, 1);

0 commit comments

Comments
 (0)