Re: [PATCH 2/2] drm/arm/komeda: fix ignored clk_prepare_enable() return value in resume

From: Liviu Dudau

Date: Fri Jun 05 2026 - 08:24:29 EST


On Sun, May 31, 2026 at 05:30:02AM +0000, Gustavo Kenji Mendonça Kaneko wrote:
> komeda_dev_resume() calls clk_prepare_enable() without checking the
> return value. If the clock fails to enable, the function returns 0
> (success) while IRQs are enabled and IOMMU is connected on potentially
> unclocked hardware, causing undefined behavior on resume.
>
> Propagate the error from clk_prepare_enable() and return early on
> failure to prevent hardware access without a valid clock.
>
> This issue was found by code review without access to Komeda hardware.

Hello,

There is nothing wrong with the content of this patch, but I would like
if anyone wants to fix these kind of problems to at least be thorough.

komeda_dev_suspend() is also ignoring the errors coming from
clk_disable_unprepare() and both fuctions before this patch always return 0,
so in komeda_drv.c we can sometimes ignore the return value. If we add
an extended version of this patch then we should also do proper error
handling in komeda_drv.c

Best regards,
Liviu


>
> Signed-off-by: Gustavo Kenji Mendonça Kaneko <kaneko.dev@xxxxx>
> ---
> drivers/gpu/drm/arm/display/komeda/komeda_dev.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> index 5ba62e637a61..9aad1d1d28ec 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
> @@ -313,7 +313,11 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
>
> int komeda_dev_resume(struct komeda_dev *mdev)
> {
> - clk_prepare_enable(mdev->aclk);
> + int err;
> +
> + err = clk_prepare_enable(mdev->aclk);
> + if (err)
> + return err;
>
> mdev->funcs->enable_irq(mdev);
>
> --
> 2.54.0
>
>

--
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯