From: Yang Zi <2959243019@qq.com>
To: aacraid@microsemi.com, James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: ips: Fix NULL pointer dereference in ips_release()
Date: Tue, 25 Aug 2026 17:25:00 +0800 [thread overview]
Message-ID: <tencent_F38F19C2D497EC19AF3331BC5030EFEF3307@qq.com> (raw)
When ips_insert_device() fails before calling pci_set_drvdata(), the
PCI device's drvdata is NULL. The .remove callback ips_remove_device()
then calls ips_release(NULL), which immediately calls
scsi_remove_host(NULL). That dereferences shost->scan_mutex at a fixed
offset of the NULL pointer, triggering a NULL pointer dereference.
KASAN report:
BUG: KASAN: null-ptr-deref in __mutex_lock_common kernel/locking/mutex.c:625 [inline]
BUG: KASAN: null-ptr-deref in __mutex_lock+0x8b/0x1010 kernel/locking/mutex.c:820
Read of size 8 at addr 00000000000000d0 by task syz.0.671/5574
__mutex_lock+0x8b/0x1010 kernel/locking/mutex.c:820
scsi_remove_host+0x24/0x300 drivers/scsi/hosts.c:169
ips_release drivers/scsi/ips.c:654 [inline] [ips]
ips_remove_device+0x155/0x2840 drivers/scsi/ips.c:6701 [ips]
Make ips_release() handle a NULL Scsi_Host by returning early, so the
remove path is safe when probe never established drvdata.
Signed-off-by: Yang Zi <2959243019@qq.com>
---
drivers/scsi/ips.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index 41ed73966a48..39568a7effb3 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -649,6 +649,9 @@ static void ips_release(struct Scsi_Host *sh)
ips_ha_t *ha;
int i;
+ if (!sh)
+ return;
+
METHOD_TRACE("ips_release", 1);
scsi_remove_host(sh);
next reply other threads:[~2026-08-25 9:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:25 Yang Zi [this message]
2026-08-25 10:44 ` [PATCH] scsi: ips: Fix NULL pointer dereference in ips_release() John Garry
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=tencent_F38F19C2D497EC19AF3331BC5030EFEF3307@qq.com \
--to=2959243019@qq.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=aacraid@microsemi.com \
--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