From: John Garry <john.g.garry@oracle.com>
To: Damien Le Moal <dlemoal@kernel.org>,
John Garry <john.garry@linux.dev>,
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
Subject: Re: [PATCH] scsi: sd: fix error handling for sd_large_pool_create() call failure
Date: Wed, 8 Jul 2026 06:14:48 +0100 [thread overview]
Message-ID: <fd2813dc-3db6-46a2-8aa4-30326b5deab2@oracle.com> (raw)
In-Reply-To: <a19a428e-9e66-42ea-b95c-f4954b67ac87@kernel.org>
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@oracle.com>
>
> Xiuwei posted a series fixing this already:
>
> https://lore.kernel.org/all/20260707030333.22245-1-yangxiuwei@kylinos.cn/
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;
>> }
>> }
>>
>
>
prev parent reply other threads:[~2026-07-08 5:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 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=fd2813dc-3db6-46a2-8aa4-30326b5deab2@oracle.com \
--to=john.g.garry@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=dlemoal@kernel.org \
--cc=john.garry@linux.dev \
--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