The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: fix error handling for sd_large_pool_create() call failure
@ 2026-07-07 10:55 John Garry
  2026-07-08  3:39 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: John Garry @ 2026-07-07 10:55 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen
  Cc: p.raghav, sw.prabhu6, linux-scsi, linux-kernel, John Garry,
	John Garry

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-08  5:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 10:55 [PATCH] scsi: sd: fix error handling for sd_large_pool_create() call failure John Garry
2026-07-08  3:39 ` Damien Le Moal
2026-07-08  5:14   ` John Garry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox