summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChaohai Chen <wdhh66@163.com>2025-01-24 16:55:42 +0800
committerMartin K. Petersen <martin.petersen@oracle.com>2025-02-12 20:50:00 -0500
commit04ad06e41d1c74cc323b20a7bd023c47bd0e0c38 (patch)
treec3ce42db1e07be9aa1c33321d6899707761816af
parentb50532318793d28a7628c1ffc129a2226e83e495 (diff)
downloadlinux-stable-04ad06e41d1c74cc323b20a7bd023c47bd0e0c38.tar.gz
linux-stable-04ad06e41d1c74cc323b20a7bd023c47bd0e0c38.tar.bz2
linux-stable-04ad06e41d1c74cc323b20a7bd023c47bd0e0c38.zip
scsi: target: spc: Fix loop traversal in spc_rsoc_get_descr()
Stop traversing after finding the appropriate descriptor. Signed-off-by: Chaohai Chen <wdhh66@163.com> Link: https://lore.kernel.org/r/20250124085542.109088-1-wdhh66@163.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/target/target_core_spc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 61c065702350..701dcbd7b63c 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -2151,8 +2151,10 @@ spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
if (descr->serv_action_valid)
return TCM_INVALID_CDB_FIELD;
- if (!descr->enabled || descr->enabled(descr, cmd))
+ if (!descr->enabled || descr->enabled(descr, cmd)) {
*opcode = descr;
+ return TCM_NO_SENSE;
+ }
break;
case 0x2:
/*
@@ -2166,8 +2168,10 @@ spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
if (descr->serv_action_valid &&
descr->service_action == requested_sa) {
if (!descr->enabled || descr->enabled(descr,
- cmd))
+ cmd)) {
*opcode = descr;
+ return TCM_NO_SENSE;
+ }
} else if (!descr->serv_action_valid)
return TCM_INVALID_CDB_FIELD;
break;
@@ -2180,13 +2184,15 @@ spc_rsoc_get_descr(struct se_cmd *cmd, struct target_opcode_descriptor **opcode)
*/
if (descr->service_action == requested_sa)
if (!descr->enabled || descr->enabled(descr,
- cmd))
+ cmd)) {
*opcode = descr;
+ return TCM_NO_SENSE;
+ }
break;
}
}
- return 0;
+ return TCM_NO_SENSE;
}
static sense_reason_t