Re: [PATCH] scsi: sd: fix error handling for sd_large_pool_create() call failure
From: John Garry
Date: Wed Jul 08 2026 - 01:20:13 EST
On 08/07/2026 04:39, Damien Le Moal wrote:
On 7/7/26 19:55, John Garry wrote:
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@xxxxxxxxxx>
Xiuwei posted a series fixing this already:
https://lore.kernel.org/all/20260707030333.22245-1-yangxiuwei@xxxxxxxxxx/
ah, I meant to check that series. cheers
---
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;
}
}