mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
drm/arm/komeda: fix error handling for clk_prepare_enable() and callers
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>
This commit is contained in:
parent
46f715a169
commit
6502eb8cfc
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 @@ static int komeda_platform_probe(struct platform_device *pdev)
|
|||
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 = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user