diff options
author | Inki Dae <inki.dae@samsung.com> | 2023-11-01 18:36:51 +0900 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2023-11-21 07:41:11 +0900 |
commit | a30ba4bd7cdb5726d86a557c5df8df71c7bc7fad (patch) | |
tree | 23efa76de34af02d1aa4cdf1739d0bd4fe9e976b | |
parent | bcfed6e96cc429b03d34c330f6c3a15475e126df (diff) | |
download | drm-exynos-fixes/exynos-drm-fixes-for-v6.7-rc3.tar.gz |
drm/exynos: fix a wrong error checkingexynos-drm-fixes-for-v6.7-rc3fixes/exynos-drm-fixes-for-v6.7-rc3
Fix a wrong error checking in exynos_drm_dma.c module.
In the exynos_drm_register_dma function, both arm_iommu_create_mapping()
and iommu_get_domain_for_dev() functions are expected to return NULL as
an error.
However, the error checking is performed using the statement if(IS_ERR(mapping)),
which doesn't provide a suitable error value. So check if 'mapping' is NULL,
and if it is, return ERR_PTR(-ENODEV).
This issue[1] was reported by Dan.
[1] https://lore.kernel.org/all/33e52277-1349-472b-a55b-ab5c3462bfcf@moroto.mountain/
Reported-by : Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_dma.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c index a971590b813230..6d73d4dca583e7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c @@ -107,18 +107,16 @@ int exynos_drm_register_dma(struct drm_device *drm, struct device *dev, return 0; if (!priv->mapping) { - void *mapping; + void *mapping = NULL; if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) mapping = arm_iommu_create_mapping(&platform_bus_type, EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); else if (IS_ENABLED(CONFIG_IOMMU_DMA)) mapping = iommu_get_domain_for_dev(priv->dma_dev); - else - mapping = ERR_PTR(-ENODEV); - if (IS_ERR(mapping)) - return PTR_ERR(mapping); + if (!mapping) + return PTR_ERR(-ENODEV); priv->mapping = mapping; } |