]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/arm/komeda: fix error handling for clk_prepare_enable() and callers
authorGustavo Kenji Mendonça Kaneko <kaneko.dev@pm.me>
Tue, 9 Jun 2026 13:08:33 +0000 (13:08 +0000)
committerLiviu Dudau <liviu.dudau@arm.com>
Tue, 30 Jun 2026 14:26:54 +0000 (15:26 +0100)
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 fix all call sites
in komeda_drv.c that previously ignored the return value of
komeda_dev_resume():

- komeda_platform_probe(): if resume fails, jump to err_destroy_mdev
  (skipping the suspend call, since the clock was never enabled)
- komeda_pm_resume(): propagate the error and skip
  drm_mode_config_helper_resume() on failure

This issue was found by code review without access to Komeda hardware.

Signed-off-by: Gustavo Kenji Mendonça Kaneko <kaneko.dev@pm.me>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patch.msgid.link/20260609130828.1066038-1-kaneko.dev@pm.me
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
drivers/gpu/drm/arm/display/komeda/komeda_dev.c
drivers/gpu/drm/arm/display/komeda/komeda_drv.c

index 5ba62e637a61693785e5a37f9694262b19b292f4..9aad1d1d28ec0c12c92d886fdb794488b116f16b 100644 (file)
@@ -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);
 
index 4bb5f250e95efad24aab11948f8efd03fc058e26..67fffab018ae8a46192c156c85d83983dfd4345a 100644 (file)
@@ -74,8 +74,11 @@ static int komeda_platform_probe(struct platform_device *pdev)
        }
 
        pm_runtime_enable(dev);
-       if (!pm_runtime_enabled(dev))
-               komeda_dev_resume(mdrv->mdev);
+       if (!pm_runtime_enabled(dev)) {
+               err = komeda_dev_resume(mdrv->mdev);
+               if (err)
+                       goto err_destroy_mdev;
+       }
 
        mdrv->kms = komeda_kms_attach(mdrv->mdev);
        if (IS_ERR(mdrv->kms)) {
@@ -93,7 +96,7 @@ destroy_mdev:
                pm_runtime_disable(dev);
        else
                komeda_dev_suspend(mdrv->mdev);
-
+err_destroy_mdev:
        komeda_dev_destroy(mdrv->mdev);
 
 free_mdrv:
@@ -140,11 +143,12 @@ static int __maybe_unused komeda_pm_suspend(struct device *dev)
 static int __maybe_unused komeda_pm_resume(struct device *dev)
 {
        struct komeda_drv *mdrv = dev_get_drvdata(dev);
+       int err = 0;
 
        if (!pm_runtime_status_suspended(dev))
-               komeda_dev_resume(mdrv->mdev);
+               err = komeda_dev_resume(mdrv->mdev);
 
-       return drm_mode_config_helper_resume(&mdrv->kms->base);
+       return err ? err : drm_mode_config_helper_resume(&mdrv->kms->base);
 }
 
 static const struct dev_pm_ops komeda_pm_ops = {