All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: target: iblock: Fix wrong PR ops NULL check for PREEMPT/RELEASE
@ 2026-07-24  7:58 kensanya
  2026-07-24  8:12 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: kensanya @ 2026-07-24  7:58 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: Hannes Reinecke, Mike Christie, linux-scsi, target-devel,
	TanZheng

From: TanZheng <tanzheng@kylinos.cn>

In the iblock_execute_pr_out function, PRO_PREEMPT, PRO_PREEMPT_AND_ABORT
and PRO_RELEASE all perform callback capability checks through
ops->pr_clear. The error check allows unimplemented hooks to pass through
the gate, resulting  dereferencing a NULL function pointer.

Check whether the hooks that need to be called are supported.

Fixes: 394f81184882 ("scsi: target: Add block PR support to iblock")
Signed-off-by: TanZheng <tanzheng@kylinos.cn>
---
 drivers/target/target_core_iblock.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 1087d1d17c36..ea65d39fef88 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -906,7 +906,7 @@ static sense_reason_t iblock_execute_pr_out(struct se_cmd *cmd, u8 sa, u64 key,
 		break;
 	case PRO_PREEMPT:
 	case PRO_PREEMPT_AND_ABORT:
-		if (!ops->pr_clear) {
+		if (!ops->pr_preempt) {
 			pr_err("block_device does not support pr_preempt.\n");
 			return TCM_UNSUPPORTED_SCSI_OPCODE;
 		}
@@ -916,8 +916,8 @@ static sense_reason_t iblock_execute_pr_out(struct se_cmd *cmd, u8 sa, u64 key,
 				      sa == PRO_PREEMPT_AND_ABORT);
 		break;
 	case PRO_RELEASE:
-		if (!ops->pr_clear) {
-			pr_err("block_device does not support pr_pclear.\n");
+		if (!ops->pr_release) {
+			pr_err("block_device does not support pr_release.\n");
 			return TCM_UNSUPPORTED_SCSI_OPCODE;
 		}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-24  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24  7:58 [PATCH] scsi: target: iblock: Fix wrong PR ops NULL check for PREEMPT/RELEASE kensanya
2026-07-24  8:12 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.