Skip to content

Commit 7db0e0c

Browse files
kawasakimartinkpetersen
authored andcommitted
scsi: scsi_debug: Fix buffer size of REPORT ZONES command
According to ZBC and SPC specifications, the unit of ALLOCATION LENGTH field of REPORT ZONES command is byte. However, current scsi_debug implementation handles it as number of zones to calculate buffer size to report zones. When the ALLOCATION LENGTH has a large number, this results in too large buffer size and causes memory allocation failure. Fix the failure by handling ALLOCATION LENGTH as byte unit. Link: https://lore.kernel.org/r/[email protected] Fixes: f0d1cf9 ("scsi: scsi_debug: Add ZBC zone commands") Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 3fe5185 commit 7db0e0c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4342,7 +4342,7 @@ static int resp_report_zones(struct scsi_cmnd *scp,
43424342
rep_max_zones = min((alloc_len - 64) >> ilog2(RZONES_DESC_HD),
43434343
max_zones);
43444344

4345-
arr = kcalloc(RZONES_DESC_HD, alloc_len, GFP_ATOMIC);
4345+
arr = kzalloc(alloc_len, GFP_ATOMIC);
43464346
if (!arr) {
43474347
mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
43484348
INSUFF_RES_ASCQ);

0 commit comments

Comments
 (0)