From: John Garry <john.g.garry@oracle.com>
To: junxiao.bi@oracle.com, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com
Subject: Re: [PATCH] scsi: fix refcount leaking for "tagset_refcnt"
Date: Tue, 3 Mar 2026 11:06:16 +0000 [thread overview]
Message-ID: <99a40eeb-497c-49a0-8f7a-8075800c1dce@oracle.com> (raw)
In-Reply-To: <e2d21ea3-bcd1-4502-9936-e54ac9f5f96f@oracle.com>
On 02/03/2026 20:36, junxiao.bi@oracle.com wrote:
>> At this point scsi_sysfs_device_initialize() has been called. Then if
>> you check the comment in __scsi_remove_device():
>>
>> Paired with kref_get() in scsi_sysfs_device_initialize()*
>>
>> So I wonder why we don't call __scsi_remove_device() instead, which
>> calls scsi_target_reap().
>>
>> Indeed, the current error handling in scsi_alloc_sdev() is odd - we
>> only call __scsi_remove_device() for ->sdev_init() failure, but
>> nothing happens between calling ->sdev_init() and after
>> scsi_sysfs_device_initialize() which means that at this point we
>> should only now call __scsi_remove_device().
>>
>> * I think that should be scsi_sysfs_initialize() and has always been
>> incorrect
>
> Good catch. Thanks John. I will send a v2 with this:
>
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 60c06fa4ec32..c2f70de5c093 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -361,9 +361,7 @@ static struct scsi_device *scsi_alloc_sdev(struct
> scsi_target *starget,
> * since we use this queue depth most of times.
> */
> if (scsi_realloc_sdev_budget_map(sdev, depth)) {
> - put_device(&starget->dev);
> - kfree(sdev);
> - goto out;
> + goto out_device_destroy;
> }
>
> scsi_change_queue_depth(sdev, depth);
NP and sorry the late review. I think that Martin has already queued
your v1 in his fixes branch...
next prev parent reply other threads:[~2026-03-03 11:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 23:27 [PATCH] scsi: fix refcount leaking for "tagset_refcnt" Junxiao Bi
2026-02-27 18:32 ` Mike Christie
2026-02-27 18:46 ` Bart Van Assche
2026-02-28 22:28 ` Martin K. Petersen
2026-03-01 2:11 ` Martin K. Petersen
2026-03-02 10:30 ` John Garry
2026-03-02 20:36 ` junxiao.bi
2026-03-03 11:06 ` John Garry [this message]
2026-03-03 16:58 ` junxiao.bi
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=99a40eeb-497c-49a0-8f7a-8075800c1dce@oracle.com \
--to=john.g.garry@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=junxiao.bi@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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