From: Aleksey Shishkin <demonaxsh@gmail.com>
Cc: linux-kernel@ispras.ru, Aleksey Shishkin <aishishkin@cloud.ru>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Kees Cook <kees@kernel.org>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: scsi_dh_rdac: fix NULL pointer dereference in error handling
Date: Mon, 13 Jul 2026 09:36:28 +0300 [thread overview]
Message-ID: <20260713063640.3081603-1-demonaxsh@gmail.com> (raw)
From: Aleksey Shishkin <aishishkin@cloud.ru>
There is a critical logic error in error handling. If get_controller()
fails and returns NULL, the function sets err = SCSI_DH_RES_TEMP_UNAVAIL.
However, immediately after spin_unlock(), the code unconditionally
overwrites err with SCSI_DH_OK.
This causes the kernel to falsely report a successful initialization,
leading to an inevitable Null Pointer Dereference (Kernel Panic) later
when the driver attempts to use the uninitialized h->ctlr.
Fix this by moving the assignment err = SCSI_DH_OK inside the else block
so it is only set when the controller is successfully acquired.
Signed-off-by: Aleksey Shishkin <aishishkin@cloud.ru>
---
drivers/scsi/device_handler/scsi_dh_rdac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 88c8e36b221e..ed02e1737bd7 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -455,9 +455,9 @@ static int initialize_controller(struct scsi_device *sdev,
else {
h->sdev = sdev;
list_add_rcu(&h->node, &h->ctlr->dh_list);
+ err = SCSI_DH_OK;
}
spin_unlock(&list_lock);
- err = SCSI_DH_OK;
}
return err;
}
--
2.47.3
next reply other threads:[~2026-07-13 6:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 6:36 Aleksey Shishkin [this message]
2026-07-13 6:53 ` [PATCH] scsi: scsi_dh_rdac: fix NULL pointer dereference in error handling sashiko-bot
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=20260713063640.3081603-1-demonaxsh@gmail.com \
--to=demonaxsh@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=aishishkin@cloud.ru \
--cc=kees@kernel.org \
--cc=linux-kernel@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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