From: Johan Hovold <johan@kernel.org>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Marco Crivellari <marco.crivellari@suse.com>,
Ben Hoff <hoff.benjamin.k@gmail.com>,
Yuhao Jiang <danisjiang@gmail.com>,
William Wu <william.wu@rock-chips.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] usb: gadget: f_hid: fix device reference leak in hidg_alloc()
Date: Mon, 13 Apr 2026 09:40:13 +0200 [thread overview]
Message-ID: <adyd3Ud2Pl_KRl6_@hovoldconsulting.com> (raw)
In-Reply-To: <20260412161555.2568840-1-lgs201920130244@gmail.com>
On Mon, Apr 13, 2026 at 12:15:55AM +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.
Good catch.
> Route the dev_set_name() failure path through err_put_device so the
> device reference is dropped properly.
>
> Fixes: 944fe915d00d ("usb: gadget: f_hid: tidy error handling in hidg_alloc")
This isn't the commit that introduced the issue, though. This should be:
Fixes: 89ff3dfac604 ("usb: gadget: f_hid: fix f_hidg lifetime vs cdev")
With that fixed you can add my:
Reviewed-by: Johan Hovold <johan@kernel.org>
Johan
next prev parent reply other threads:[~2026-04-13 7:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 16:15 [PATCH] usb: gadget: f_hid: fix device reference leak in hidg_alloc() Guangshuo Li
2026-04-13 7:40 ` Johan Hovold [this message]
2026-04-13 7:58 ` 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=adyd3Ud2Pl_KRl6_@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=andrzej.p@collabora.com \
--cc=danisjiang@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hoff.benjamin.k@gmail.com \
--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