The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: John Garry <john.garry@linux.dev>
To: James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com
Cc: p.raghav@samsung.com, sw.prabhu6@gmail.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	John Garry <john.garry@linux.dev>,
	John Garry <john.g.garry@oracle.com>
Subject: [PATCH] scsi: sd: fix error handling for sd_large_pool_create() call failure
Date: Tue,  7 Jul 2026 11:55:55 +0100	[thread overview]
Message-ID: <20260707105555.1382237-1-john.garry@linux.dev> (raw)

If the sd_probe() -> sd_large_pool_create() call fails, then we incorrectly
unwind the probe actions.

Currently for the sd_large_pool_create() failure we do no undo the
device_add() call.

Fix this by mimicking the handling of device_add_disk() failure, in calling
device_unregister() and put_disk(). The device_unregister() call will
result in scsi_disk_release() being called, which unwinds many actions in
sd_probe().

Fixes: 7179e626b76e ("scsi: sd: Enable sector size > PAGE_SIZE in SCSI sd driver")
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
I do wonder if it is simpler to always create this pool when we can
support LBS. We only create a min of two elements in the pool, so
hardly large.

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 599e75f33334..d18693d390b2 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -4089,7 +4089,9 @@ static int sd_probe(struct scsi_device *sdp)
 	if (sdp->sector_size > PAGE_SIZE) {
 		if (sd_large_pool_create()) {
 			error = -ENOMEM;
-			goto out_free_index;
+			device_unregister(&sdkp->disk_dev);
+			put_disk(gd);
+			goto out;
 		}
 	}
 
-- 
2.43.0


             reply	other threads:[~2026-07-07 10:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 10:55 John Garry [this message]
2026-07-08  3:39 ` [PATCH] scsi: sd: fix error handling for sd_large_pool_create() call failure Damien Le Moal
2026-07-08  5:14   ` 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=20260707105555.1382237-1-john.garry@linux.dev \
    --to=john.garry@linux.dev \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=p.raghav@samsung.com \
    --cc=sw.prabhu6@gmail.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