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>
Wed, 15 Sep 2021 07:50:44 +0000 (09:50 +0200)
commit9ee4ff8cbe392669e187e9c370a09d16493ae1ef
treecf537f641d00a9a01ff110cddc75f93e21b6bd69
parent4d2823abd1fe4e21653b3efafdbefa012d9d38d4
usb: bdc: Fix a resource leak in the error handling path of 'bdc_probe()'

[ Upstream commit 6f15a2a09cecb7a2faba4a75bbd101f6f962294b ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/udc/bdc/bdc_core.c