From: Johan Hovold <johan@kernel.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] usb-serial: fix port device refcount leak when device_add() fails
Date: Mon, 13 Apr 2026 08:57:46 +0200 [thread overview]
Message-ID: <adyT6oW0UgvcEQbX@hovoldconsulting.com> (raw)
In-Reply-To: <20260412165311.2578501-1-lgs201920130244@gmail.com>
On Mon, Apr 13, 2026 at 12:53:11AM +0800, Guangshuo Li wrote:
> usb_serial_probe() initializes each port device with
> device_initialize() before registering it with device_add().
>
> If device_add() fails, the current code only logs an error and
> continues, but does not drop the reference acquired by
> device_initialize(). This leaves the failed port device referenced
> until a later teardown path, if any.
>
> Fix it by calling put_device() when device_add() fails. Also clear
> serial->port[i] after put_device() so destroy_serial() will not try
> to put the same device again.
Any port that fails to register is released in destroy_serial() which is
called when the last reference to the device is dropped (e.g. when the
device is disconnected).
So there is nothing to fix here.
Are you using some kind of tool to find these "issues"?
Johan
next prev parent reply other threads:[~2026-04-13 6:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 16:53 Guangshuo Li
2026-04-13 6:57 ` Johan Hovold [this message]
2026-04-13 7:55 ` Guangshuo Li
2026-04-13 8:10 ` Johan Hovold
2026-04-13 8:18 ` Guangshuo Li
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=adyT6oW0UgvcEQbX@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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
all inboxes | Powered by JetHome®