Skip to content
/ linux Public

Commit 0d28aee

Browse files
Artem ShimkoSasha Levin
authored andcommitted
serial: 8250_dw: handle clock enable errors in runtime_resume
[ Upstream commit d312281 ] Add error checking for clk_prepare_enable() calls in dw8250_runtime_resume(). Currently if either clock fails to enable, the function returns success while leaving clocks in inconsistent state. This change implements comprehensive error handling by checking the return values of both clk_prepare_enable() calls. If the second clock enable operation fails after the first clock has already been successfully enabled, the code now properly cleans up by disabling and unpreparing the first clock before returning. The error code is then propagated to the caller, ensuring that clock enable failures are properly reported rather than being silently ignored. Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com> Link: https://patch.msgid.link/20251104145433.2316165-2-a.shimko.dev@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ff74681 commit 0d28aee

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,18 @@ static int dw8250_runtime_suspend(struct device *dev)
738738

739739
static int dw8250_runtime_resume(struct device *dev)
740740
{
741+
int ret;
741742
struct dw8250_data *data = dev_get_drvdata(dev);
742743

743-
clk_prepare_enable(data->pclk);
744+
ret = clk_prepare_enable(data->pclk);
745+
if (ret)
746+
return ret;
744747

745-
clk_prepare_enable(data->clk);
748+
ret = clk_prepare_enable(data->clk);
749+
if (ret) {
750+
clk_disable_unprepare(data->pclk);
751+
return ret;
752+
}
746753

747754
return 0;
748755
}

0 commit comments

Comments
 (0)