OSDN Git Service

PM: runtime: clk: Fix clk_pm_runtime_get() error path
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 21 May 2020 17:08:09 +0000 (19:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:05:03 +0000 (09:05 +0200)
commit3834e636b3910f59b4f499e3cf4139937cc078dc
tree67c2313f72de8d3c3c6951febeb3089004dbfd97
parent1590ebfa8d3578135b78c9b0d5bc9551e6ef556e
PM: runtime: clk: Fix clk_pm_runtime_get() error path

commit 64c7d7ea22d86cacb65d0c097cc447bc0e6d8abd upstream.

clk_pm_runtime_get() assumes that the PM-runtime usage counter will
be dropped by pm_runtime_get_sync() on errors, which is not the case,
so PM-runtime references to devices acquired by the former are leaked
on errors returned by the latter.

Fix this by modifying clk_pm_runtime_get() to drop the reference if
pm_runtime_get_sync() returns an error.

Fixes: 9a34b45397e5 clk: Add support for runtime PM
Cc: 4.15+ <stable@vger.kernel.org> # 4.15+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/clk.c