Skip to content
/ linux Public

Commit 32ccda4

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 52b42c2 commit 32ccda4

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
@@ -753,11 +753,18 @@ static int dw8250_runtime_suspend(struct device *dev)
753753

754754
static int dw8250_runtime_resume(struct device *dev)
755755
{
756+
int ret;
756757
struct dw8250_data *data = dev_get_drvdata(dev);
757758

758-
clk_prepare_enable(data->pclk);
759+
ret = clk_prepare_enable(data->pclk);
760+
if (ret)
761+
return ret;
759762

760-
clk_prepare_enable(data->clk);
763+
ret = clk_prepare_enable(data->clk);
764+
if (ret) {
765+
clk_disable_unprepare(data->pclk);
766+
return ret;
767+
}
761768

762769
return 0;
763770
}

0 commit comments

Comments
 (0)