OSDN Git Service

usb: bdc: Fix a resource leak in the error handling path of 'bdc_probe()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 18 Aug 2021 19:32:49 +0000 (21:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Aug 2021 11:34:52 +0000 (13:34 +0200)
commit6f15a2a09cecb7a2faba4a75bbd101f6f962294b
treea702b5a80b6178766dd532233f7a0823c80ec499
parentd2f42e09393c774ab79088d8e3afcc62b3328fc9
usb: bdc: Fix a resource leak in the error handling path of 'bdc_probe()'

If an error occurs after a successful 'clk_prepare_enable()' call, it must
be undone by a corresponding 'clk_disable_unprepare()' call.
This call is already present in the remove function.

Add this call in the error handling path and reorder the code so that the
'clk_prepare_enable()' call happens later in the function.
The goal is to have as much managed resources functions as possible
before the 'clk_prepare_enable()' call in order to keep the error handling
path simple.

While at it, remove the now unneeded 'clk' variable.

Fixes: c87dca047849 ("usb: bdc: Add clock enable for new chips with a separate BDC clock")
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/f8a4a6897deb0c8cb2e576580790303550f15fcd.1629314734.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/bdc/bdc_core.c