mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
FROMGIT: scsi: sd: sd_zbc: Verify that the zone size is a power of two
The following check in sd_zbc_cmnd_checks() can only work correctly if the
zone size is a power of two:
if (sector & (sd_zbc_zone_sectors(sdkp) - 1))
/* Unaligned request */
return BLK_STS_IOERR;
Hence this patch that verifies that the zone size is a power of two.
Link: https://lore.kernel.org/r/20220421183023.3462291-3-bvanassche@acm.org
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 230616396
(cherry picked from commit 9a93b9c9d3 mkp-scsi/staging)
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Change-Id: I99b06e3dbc4f99d3696edde0af60e8fb876745b7
This commit is contained in:
committed by
Jaegeuk Kim
parent
fa33f94b99
commit
90f56ddc36
@@ -666,6 +666,13 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf,
|
||||
return -EFBIG;
|
||||
}
|
||||
|
||||
if (!is_power_of_2(zone_blocks)) {
|
||||
sd_printk(KERN_ERR, sdkp,
|
||||
"Zone size %llu is not a power of two.\n",
|
||||
zone_blocks);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*zblocks = zone_blocks;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user