]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: target: iblock: Fix wrong PR ops NULL check for PREEMPT/RELEASE
authorTanZheng <tanzheng@kylinos.cn>
Fri, 24 Jul 2026 07:58:50 +0000 (15:58 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 29 Jul 2026 01:52:08 +0000 (21:52 -0400)
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>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Link: https://patch.msgid.link/20260724075850.280699-1-kensanya@163.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_iblock.c

index 1087d1d17c36dd0742ebc0dcccedc933aa1168cd..ea65d39fef884be520d73a8389cc50cbf723f911 100644 (file)
@@ -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;
                }