public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Inki Dae <inki.dae@samsung.com>, Sasha Levin <sashal@kernel.org>,
	sw0312.kim@samsung.com, kyungmin.park@samsung.com,
	airlied@gmail.com, daniel@ffwll.ch,
	krzysztof.kozlowski@linaro.org, dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 27/29] drm/exynos: fix a wrong error checking
Date: Mon, 11 Dec 2023 08:54:11 -0500	[thread overview]
Message-ID: <20231211135457.381397-27-sashal@kernel.org> (raw)
In-Reply-To: <20231211135457.381397-1-sashal@kernel.org>

From: Inki Dae <inki.dae@samsung.com>

[ Upstream commit 8d1b7809684c688005706125b804e1f9792d2b1b ]

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 -ENODEV.

This issue[1] was reported by Dan.

Changelog v1:
- fix build warning.

[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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/exynos/exynos_drm_dma.c | 8 +++-----
 1 file 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 a971590b81323..e2c7373f20c6b 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 -ENODEV;
 		priv->mapping = mapping;
 	}
 
-- 
2.42.0


  parent reply	other threads:[~2023-12-11 13:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 13:53 [PATCH AUTOSEL 6.1 01/29] hwtracing: hisi_ptt: Handle the interrupt in hardirq context Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 02/29] hwtracing: hisi_ptt: Don't try to attach a task Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 03/29] ASoC: wm8974: Correct boost mixer inputs Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 04/29] arm64: dts: rockchip: fix rk356x pcie msg interrupt name Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 05/29] ASoC: Intel: Skylake: Fix mem leak in few functions Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 06/29] ASoC: nau8822: Fix incorrect type in assignment and cast to restricted __be16 Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 07/29] ASoC: Intel: Skylake: mem leak in skl register function Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 08/29] ASoC: cs43130: Fix the position of const qualifier Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 09/29] ASoC: cs43130: Fix incorrect frame delay configuration Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 10/29] ASoC: rt5650: add mutex to avoid the jack detection failure Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 11/29] ASoC: SOF: mediatek: mt8186: Add Google Steelix topology compatible Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 12/29] ASoC: Intel: skl_hda_dsp_generic: Drop HDMI routes when HDMI is not available Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 13/29] nouveau/tu102: flush all pdbs on vmm flush Sasha Levin
2023-12-11 14:10   ` Timur Tabi
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 14/29] ASoC: amd: yc: Add DMI entry to support System76 Pangolin 13 Sasha Levin
2023-12-11 13:53 ` [PATCH AUTOSEL 6.1 15/29] ASoC: hdac_hda: Conditionally register dais for HDMI and Analog Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 16/29] net/tg3: fix race condition in tg3_reset_task() Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 17/29] ASoC: da7219: Support low DC impedance headset Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 18/29] ASoC: ops: add correct range check for limiting volume Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 19/29] nvme: introduce helper function to get ctrl state Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 20/29] nvme: prevent potential spectre v1 gadget Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 21/29] arm64: dts: rockchip: Fix PCI node addresses on rk3399-gru Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 22/29] mips/smp: Call rcutree_report_cpu_starting() earlier Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 23/29] drm/amd/display: Use channel_width = 2 for vram table 3.0 Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 24/29] drm/amd/display: Add monitor patch for specific eDP Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 25/29] drm/amdgpu: Add NULL checks for function pointers Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 26/29] drm/exynos: fix a potential error pointer dereference Sasha Levin
2023-12-11 13:54 ` Sasha Levin [this message]
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 28/29] hwmon: (corsair-psu) Fix probe when built-in Sasha Levin
2023-12-11 13:54 ` [PATCH AUTOSEL 6.1 29/29] LoongArch: Preserve syscall nr across execve() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231211135457.381397-27-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox