Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Ruoyu Wang <ruoyuw560@gmail.com>
To: martin.petersen@oracle.com
Cc: agrover@redhat.com, roland@kernel.org, nab@linux-iscsi.org,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] scsi: target: iscsi: Clear sequence list after PDU allocation failure
Date: Tue,  7 Jul 2026 23:13:30 +0800	[thread overview]
Message-ID: <20260707151330.2334097-1-ruoyuw560@gmail.com> (raw)

iscsit_build_pdu_and_seq_lists() publishes cmd->seq_list after the
sequence-list allocation succeeds. If the later PDU-list allocation
fails, the error path frees the local seq pointer and returns with
cmd->seq_list still pointing at that freed memory.

The same command is then converted into a reject command, and its normal
release path frees cmd->seq_list again. Clear the published sequence-list
state after freeing seq so command release does not see a stale cleanup
pointer.

This issue was found by a static analysis checker and confirmed by
manual source review.
Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/target/iscsi/iscsi_target_seq_pdu_list.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c
index 75c37c8866c86..2571097436399 100644
--- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c
+++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c
@@ -549,6 +549,8 @@ int iscsit_build_pdu_and_seq_lists(
 		if (!pdu) {
 			pr_err("Unable to allocate struct iscsi_pdu list.\n");
 			kfree(seq);
+			cmd->seq_list = NULL;
+			cmd->seq_count = 0;
 			return -ENOMEM;
 		}
 		cmd->pdu_list = pdu;
-- 
2.51.0


                 reply	other threads:[~2026-07-07 15:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260707151330.2334097-1-ruoyuw560@gmail.com \
    --to=ruoyuw560@gmail.com \
    --cc=agrover@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@linux-iscsi.org \
    --cc=roland@kernel.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox