From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Marco Crivellari <marco.crivellari@suse.com>,
Johan Hovold <johan@kernel.org>, Jiri Kosina <jikos@kernel.org>,
William Wu <william.wu@rock-chips.com>,
Yuhao Jiang <danisjiang@gmail.com>,
Ben Hoff <hoff.benjamin.k@gmail.com>,
Terry Junge <linuxhid@cosmicgizmosystems.com>,
Andrzej Pietrasiewicz <andrzej.p@collabora.com>,
John Keeping <john@keeping.me.uk>, Lee Jones <lee@kernel.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: gadget: f_hid: fix device reference leak in hidg_alloc()
Date: Mon, 13 Apr 2026 12:40:23 +0200 [thread overview]
Message-ID: <2026041352-morally-campfire-c4cf@gregkh> (raw)
In-Reply-To: <20260413081237.2677048-1-lgs201920130244@gmail.com>
On Mon, Apr 13, 2026 at 04:12:37PM +0800, Guangshuo Li wrote:
> hidg_alloc() initializes hidg->dev with device_initialize() before
> calling dev_set_name(). If dev_set_name() fails, the function currently
> jumps to err_unlock and returns without calling put_device().
>
> This leaves the device reference unbalanced and prevents hidg_release()
> from being called. Calling put_device() here is also safe, since
> hidg_release() only frees resources owned by hidg.
>
> Route the dev_set_name() failure path through err_put_device so the
> device reference is dropped properly.
>
> Fixes: 89ff3dfac604 ("usb: gadget: f_hid: fix f_hidg lifetime vs cdev")
> Cc: stable@vger.kernel.org
> Reviewed-by: Johan Hovold <johan@kernel.org>
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
> v2:
> - correct Fixes tag to 89ff3dfac604
> - add Reviewed-by from Johan Hovold
As you are using a tool to find/fix these things, you HAVE to mention
that as per our documentation. Please go and read that and then
resubmit all of thes patches that need that attribution added.
thanks,
greg k-h
prev parent reply other threads:[~2026-04-13 10:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 8:12 [PATCH v2] usb: gadget: f_hid: fix device reference leak in hidg_alloc() Guangshuo Li
2026-04-13 10:40 ` Greg Kroah-Hartman [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=2026041352-morally-campfire-c4cf@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=andrzej.p@collabora.com \
--cc=danisjiang@gmail.com \
--cc=hoff.benjamin.k@gmail.com \
--cc=jikos@kernel.org \
--cc=johan@kernel.org \
--cc=john@keeping.me.uk \
--cc=lee@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linuxhid@cosmicgizmosystems.com \
--cc=marco.crivellari@suse.com \
--cc=stable@vger.kernel.org \
--cc=william.wu@rock-chips.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