From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 617E7271476; Tue, 27 May 2025 17:05:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748365526; cv=none; b=CBfGpKyh732BI8KbY+CtUMT64P0KpgLhV0ZiaItAOGjhra2LMeNl4Huug2SHFnOtZ6nbvJQh1I+7uCFEyDxPIDDhbb+U0c3gGI8U8JS8TCsUMrL0C0mi7oCJuQviWfNQYm/1jgDoTlVzcj6gFONN0o8jca0exGvBBJcEAsgNsGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748365526; c=relaxed/simple; bh=uAGlV7vpyU4gXN8OwM3GeLssXou6UITiOKzn6qXYf6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KjmxdRVZ+8Tyuknd11KdcJtq3CFM1ytGAw6OqXBu5FhTh8L3iiVc5jRdvQ8lzHZnW6zTEJCu14jR3FO8+WRSczNQfstZnhj0vBLpWMXzSICr8JItffzz58eZGw8ZKGLILbihPYEsFifVPlRB/Prx/GsuYoOLxnnhNsQqwOSWrAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uvQBjnSV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uvQBjnSV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C278AC4CEE9; Tue, 27 May 2025 17:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748365526; bh=uAGlV7vpyU4gXN8OwM3GeLssXou6UITiOKzn6qXYf6g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uvQBjnSV59sUcR+8wp/bylW6HytUuPHos7JS/qrBOURR03sQbWvv0gkMLtDhUAV4G sk2+gmCHFeJdkNtGSVvVlPKoNBqV0xB/6iV3bQyyOwcYfKuJecuCs7L0HKB0hTlMfb I0+tS/6cWRr3e/Q6VlXVhwk+q8/XUhWFeAJa+Wcs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chaohai Chen , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.12 404/626] scsi: target: spc: Fix loop traversal in spc_rsoc_get_descr() Date: Tue, 27 May 2025 18:24:57 +0200 Message-ID: <20250527162501.432639690@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250527162445.028718347@linuxfoundation.org> References: <20250527162445.028718347@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chaohai Chen [ Upstream commit 04ad06e41d1c74cc323b20a7bd023c47bd0e0c38 ] Stop traversing after finding the appropriate descriptor. Signed-off-by: Chaohai Chen Link: https://lore.kernel.org/r/20250124085542.109088-1-wdhh66@163.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/target/target_core_spc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 61c065702350e..701dcbd7b63cf 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 -- 2.39.5