block: Check bdrv_getlength() return value in bdrv_make_zero()
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
		
							parent
							
								
									da15ee5134
								
							
						
					
					
						commit
						9ce10c0bdc
					
				
							
								
								
									
										8
									
								
								block.c
								
								
								
								
							
							
						
						
									
										8
									
								
								block.c
								
								
								
								
							| 
						 | 
				
			
			@ -2749,10 +2749,16 @@ int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
 | 
			
		|||
 */
 | 
			
		||||
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
 | 
			
		||||
{
 | 
			
		||||
    int64_t target_size = bdrv_getlength(bs) / BDRV_SECTOR_SIZE;
 | 
			
		||||
    int64_t target_size;
 | 
			
		||||
    int64_t ret, nb_sectors, sector_num = 0;
 | 
			
		||||
    int n;
 | 
			
		||||
 | 
			
		||||
    target_size = bdrv_getlength(bs);
 | 
			
		||||
    if (target_size < 0) {
 | 
			
		||||
        return target_size;
 | 
			
		||||
    }
 | 
			
		||||
    target_size /= BDRV_SECTOR_SIZE;
 | 
			
		||||
 | 
			
		||||
    for (;;) {
 | 
			
		||||
        nb_sectors = target_size - sector_num;
 | 
			
		||||
        if (nb_sectors <= 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue