]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
USB: lpc32xx_udc: Fix error handling in probe
authorMa Ke <make24@iscas.ac.cn>
Mon, 15 Dec 2025 02:09:31 +0000 (10:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:50 +0000 (13:09 +0100)
commit0c2b0e747010fa645342138d71339a0ecb823bb0
tree94e9ee41f8e20c492aedd56f5ab22f99e5dc82ac
parent76b52ed875d5d3f43a4cb342707af885c2440566
USB: lpc32xx_udc: Fix error handling in probe

commit c84117912bddd9e5d87e68daf182410c98181407 upstream.

lpc32xx_udc_probe() acquires an i2c_client reference through
isp1301_get_client() but fails to release it in both error handling
paths and the normal removal path. This could result in a reference
count leak for the I2C device, preventing proper cleanup and potentially
leading to resource exhaustion. Add put_device() to release the
reference in the probe failure path and in the remove function.

Calling path: isp1301_get_client() -> of_find_i2c_device_by_node() ->
i2c_find_device_by_fwnode(). As comments of i2c_find_device_by_fwnode()
says, 'The user must call put_device(&client->dev) once done with the
i2c client.'

Found by code review.

Cc: stable <stable@kernel.org>
Fixes: 24a28e428351 ("USB: gadget driver for LPC32xx")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Link: https://patch.msgid.link/20251215020931.15324-1-make24@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/lpc32xx_udc.c