Skip to content

Commit b2f8609

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: scsi_debug: Rework page code error handling
Instead of tracking whether or not the page code is valid in a boolean variable, jump to error handling code if an unsupported page code is encountered. Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Douglas Gilbert <dgilbert@interlog.com> Tested-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20240130214911.1863909-15-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent b1e5c0b commit b2f8609

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
26442644
unsigned char *ap;
26452645
unsigned char arr[SDEBUG_MAX_MSENSE_SZ];
26462646
unsigned char *cmd = scp->cmnd;
2647-
bool dbd, llbaa, msense_6, is_disk, is_zbc, bad_pcode;
2647+
bool dbd, llbaa, msense_6, is_disk, is_zbc;
26482648

26492649
dbd = !!(cmd[1] & 0x8); /* disable block descriptors */
26502650
pcontrol = (cmd[2] & 0xc0) >> 6;
@@ -2708,7 +2708,6 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
27082708
mk_sense_invalid_fld(scp, SDEB_IN_CDB, 3, -1);
27092709
return check_condition_result;
27102710
}
2711-
bad_pcode = false;
27122711

27132712
switch (pcode) {
27142713
case 0x1: /* Read-Write error recovery page, direct access */
@@ -2723,15 +2722,17 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
27232722
if (is_disk) {
27242723
len = resp_format_pg(ap, pcontrol, target);
27252724
offset += len;
2726-
} else
2727-
bad_pcode = true;
2725+
} else {
2726+
goto bad_pcode;
2727+
}
27282728
break;
27292729
case 0x8: /* Caching page, direct access */
27302730
if (is_disk || is_zbc) {
27312731
len = resp_caching_pg(ap, pcontrol, target);
27322732
offset += len;
2733-
} else
2734-
bad_pcode = true;
2733+
} else {
2734+
goto bad_pcode;
2735+
}
27352736
break;
27362737
case 0xa: /* Control Mode page, all devices */
27372738
len = resp_ctrl_m_pg(ap, pcontrol, target);
@@ -2784,18 +2785,17 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
27842785
}
27852786
break;
27862787
default:
2787-
bad_pcode = true;
2788-
break;
2789-
}
2790-
if (bad_pcode) {
2791-
mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5);
2792-
return check_condition_result;
2788+
goto bad_pcode;
27932789
}
27942790
if (msense_6)
27952791
arr[0] = offset - 1;
27962792
else
27972793
put_unaligned_be16((offset - 2), arr + 0);
27982794
return fill_from_dev_buffer(scp, arr, min_t(u32, alloc_len, offset));
2795+
2796+
bad_pcode:
2797+
mk_sense_invalid_fld(scp, SDEB_IN_CDB, 2, 5);
2798+
return check_condition_result;
27992799
}
28002800

28012801
#define SDEBUG_MAX_MSELECT_SZ 512

0 commit comments

Comments
 (0)