@@ -486,7 +486,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf)
486
486
*/
487
487
static int sd_zbc_check_zone_size (struct scsi_disk * sdkp )
488
488
{
489
- u64 zone_blocks ;
489
+ u64 zone_blocks = 0 ;
490
490
sector_t block = 0 ;
491
491
unsigned char * buf ;
492
492
unsigned char * rec ;
@@ -504,10 +504,8 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
504
504
505
505
/* Do a report zone to get the same field */
506
506
ret = sd_zbc_report_zones (sdkp , buf , SD_ZBC_BUF_SIZE , 0 );
507
- if (ret ) {
508
- zone_blocks = 0 ;
509
- goto out ;
510
- }
507
+ if (ret )
508
+ goto out_free ;
511
509
512
510
same = buf [4 ] & 0x0f ;
513
511
if (same > 0 ) {
@@ -547,43 +545,40 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
547
545
ret = sd_zbc_report_zones (sdkp , buf ,
548
546
SD_ZBC_BUF_SIZE , block );
549
547
if (ret )
550
- return ret ;
548
+ goto out_free ;
551
549
}
552
550
553
551
} while (block < sdkp -> capacity );
554
552
555
553
zone_blocks = sdkp -> zone_blocks ;
556
554
557
555
out :
558
- kfree (buf );
559
-
560
556
if (!zone_blocks ) {
561
557
if (sdkp -> first_scan )
562
558
sd_printk (KERN_NOTICE , sdkp ,
563
559
"Devices with non constant zone "
564
560
"size are not supported\n" );
565
- return - ENODEV ;
566
- }
567
-
568
- if (!is_power_of_2 (zone_blocks )) {
561
+ ret = - ENODEV ;
562
+ } else if (!is_power_of_2 (zone_blocks )) {
569
563
if (sdkp -> first_scan )
570
564
sd_printk (KERN_NOTICE , sdkp ,
571
565
"Devices with non power of 2 zone "
572
566
"size are not supported\n" );
573
- return - ENODEV ;
574
- }
575
-
576
- if (logical_to_sectors (sdkp -> device , zone_blocks ) > UINT_MAX ) {
567
+ ret = - ENODEV ;
568
+ } else if (logical_to_sectors (sdkp -> device , zone_blocks ) > UINT_MAX ) {
577
569
if (sdkp -> first_scan )
578
570
sd_printk (KERN_NOTICE , sdkp ,
579
571
"Zone size too large\n" );
580
- return - ENODEV ;
572
+ ret = - ENODEV ;
573
+ } else {
574
+ sdkp -> zone_blocks = zone_blocks ;
575
+ sdkp -> zone_shift = ilog2 (zone_blocks );
581
576
}
582
577
583
- sdkp -> zone_blocks = zone_blocks ;
584
- sdkp -> zone_shift = ilog2 ( zone_blocks );
578
+ out_free :
579
+ kfree ( buf );
585
580
586
- return 0 ;
581
+ return ret ;
587
582
}
588
583
589
584
static int sd_zbc_setup (struct scsi_disk * sdkp )
0 commit comments