From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Yang Xiuwei <yangxiuwei@kylinos.cn>,
John Garry <john.g.garry@oracle.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15.y 4/4] scsi: sd: fix missing put_disk() when device_add(&disk_dev) fails
Date: Sat, 9 May 2026 12:08:49 -0400 [thread overview]
Message-ID: <20260509160849.3584738-4-sashal@kernel.org> (raw)
In-Reply-To: <20260509160849.3584738-1-sashal@kernel.org>
From: Yang Xiuwei <yangxiuwei@kylinos.cn>
[ Upstream commit 1e111c4b3a726df1254670a5cc4868cedb946d37 ]
If device_add(&sdkp->disk_dev) fails, put_device() runs
scsi_disk_release(), which frees the scsi_disk but leaves the gendisk
referenced. The device_add_disk() error path in sd_probe() calls
put_disk(gd); call put_disk(gd) here to mirror that cleanup.
Fixes: 265dfe8ebbab ("scsi: sd: Free scsi_disk device via put_device()")
Cc: stable@vger.kernel.org
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Link: https://patch.msgid.link/20260330014952.152776-1-yangxiuwei@kylinos.cn
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/sd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6c6cca6664c94..358354fe6c76f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3420,6 +3420,7 @@ static int sd_probe(struct device *dev)
error = device_add(&sdkp->disk_dev);
if (error) {
put_device(&sdkp->disk_dev);
+ put_disk(gd);
goto out;
}
--
2.53.0
prev parent reply other threads:[~2026-05-09 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 8:52 FAILED: patch "[PATCH] scsi: sd: fix missing put_disk() when device_add(&disk_dev)" failed to apply to 5.15-stable tree gregkh
2026-05-09 16:08 ` [PATCH 5.15.y 1/4] scsi: core: pm: Rely on the device driver core for async power management Sasha Levin
2026-05-09 16:08 ` [PATCH 5.15.y 2/4] scsi: sd: Add error handling support for add_disk() Sasha Levin
2026-05-09 16:08 ` [PATCH 5.15.y 3/4] sd: rename the scsi_disk.dev field Sasha Levin
2026-05-09 16:08 ` Sasha Levin [this message]
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=20260509160849.3584738-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
--cc=yangxiuwei@kylinos.cn \
/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