Re: [PATCH v1 0/2] usb: gadget: udc: simplify lock holding using guards

From: lihuisong (C)

Date: Mon Apr 20 2026 - 02:21:40 EST



On 4/20/2026 1:40 PM, Greg KH wrote:
On Mon, Apr 20, 2026 at 11:57:20AM +0800, Huisong Li wrote:
Simplify udc_lock and connect_lock holding using guards in
gadget_bind_driver() and gadget_unbind_driver().

Huisong Li (2):
usb: gadget: udc: simplify udc_lock holding using guards
usb: gadget: udc: simplify connect_lock holding using guards

drivers/usb/gadget/udc/core.c | 77 ++++++++++++++++-------------------
1 file changed, 35 insertions(+), 42 deletions(-)
Only do this for new drivers, don't convert existing code that works
just fine for no valid reason other than wanting to clean stuff up.

Does this fix a bug?
Here not to fix a bug. But prepare for fixing a bug in link[1].
I found that there are many unlock of udc_lock in error path after that patch.
So use the guard to simpliy them by the way.

[1]https://patchwork.kernel.org/project/linux-usb/patch/20260420040223.1232745-1-lihuisong@xxxxxxxxxx/

/Huisong