mirror of
				https://git.proxmox.com/git/mirror_zfs.git
				synced 2025-10-26 18:05:04 +03:00 
			
		
		
		
	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 <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Closes #17396
This commit is contained in:
		
							parent
							
								
									2c53fe7764
								
							
						
					
					
						commit
						04493ca819
					
				| @ -1397,13 +1397,15 @@ zvol_alloc(dev_t dev, const char *name, uint64_t volblocksize) | |||||||
| 	 */ | 	 */ | ||||||
| 	if (zv->zv_zso->use_blk_mq) { | 	if (zv->zv_zso->use_blk_mq) { | ||||||
| 		ret = zvol_alloc_blk_mq(zv, &limits); | 		ret = zvol_alloc_blk_mq(zv, &limits); | ||||||
|  | 		if (ret != 0) | ||||||
|  | 			goto out_kmem; | ||||||
| 		zso->zvo_disk->fops = &zvol_ops_blk_mq; | 		zso->zvo_disk->fops = &zvol_ops_blk_mq; | ||||||
| 	} else { | 	} else { | ||||||
| 		ret = zvol_alloc_non_blk_mq(zso, &limits); | 		ret = zvol_alloc_non_blk_mq(zso, &limits); | ||||||
| 		zso->zvo_disk->fops = &zvol_ops; |  | ||||||
| 	} |  | ||||||
| 		if (ret != 0) | 		if (ret != 0) | ||||||
| 			goto out_kmem; | 			goto out_kmem; | ||||||
|  | 		zso->zvo_disk->fops = &zvol_ops; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Limit read-ahead to a single page to prevent over-prefetching. */ | 	/* Limit read-ahead to a single page to prevent over-prefetching. */ | ||||||
| 	blk_queue_set_read_ahead(zso->zvo_queue, 1); | 	blk_queue_set_read_ahead(zso->zvo_queue, 1); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Rob Norris
						Rob Norris