Skip to contentSkip to conversation

drivers/perf: fix return value check in ali_drw_pmu_probe()

PATCH Applied Sun Ke 4 participants 4 messages Sep 24, 2022 – Oct 7, 2022

Subsystems (3)
lore
Share & tools
lore

Sun Ke

author
#0 lore raw

PATCH 1/1 drivers/perf: fix return value check in ali_drw_pmu_probe()

In case of error, devm_ioremap_resource() returns ERR_PTR(), and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")
---
 drivers/perf/alibaba_uncore_drw_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +2 -2
index 82729b874f09..a7689fecb49d 100644
@@ -658,8 +658,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	drw_pmu->cfg_base = devm_ioremap_resource(&pdev->dev, res);
-	if (!drw_pmu->cfg_base)
-		return -ENOMEM;
+	if (IS_ERR(drw_pmu->cfg_base))
+		return PTR_ERR(drw_pmu->cfg_base);
 
 	name = devm_kasprintf(drw_pmu->dev, GFP_KERNEL, "ali_drw_%llx",
 			      (u64) (res->start >> ALI_DRW_PMU_PA_SHIFT));
Signature · 1 line
2.31.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Sun Ke

In case of error, devm_ioremap_resource() returns ERR_PTR(), and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")

Good catch, thank you for fixing.

Cheers,
Shuai

Quoted 19 lines
---
 drivers/perf/alibaba_uncore_drw_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +2 -2
index 82729b874f09..a7689fecb49d 100644
@@ -658,8 +658,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	drw_pmu->cfg_base = devm_ioremap_resource(&pdev->dev, res);
-	if (!drw_pmu->cfg_base)
-		return -ENOMEM;
+	if (IS_ERR(drw_pmu->cfg_base))
+		return PTR_ERR(drw_pmu->cfg_base);
 
 	name = devm_kasprintf(drw_pmu->dev, GFP_KERNEL, "ali_drw_%llx",
 			      (u64) (res->start >> ALI_DRW_PMU_PA_SHIFT));
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Sun Ke
Quoted 15 lines · Sun Ke

In case of error, devm_ioremap_resource() returns ERR_PTR(), and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Fixes cf7b61073e45 ("drivers/perf: add DDR Sub-System Driveway PMU driver for Yitian 710 SoC")
---
 drivers/perf/alibaba_uncore_drw_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/alibaba_uncore_drw_pmu.c +0 -0
index 82729b874f09..a7689fecb49d 100644

drivers/perf/alibaba_uncore_drw_pmu.c static int ali_drw_pmu_probe(struct platform_device *pdev) · line 665

Quoted 10 lines
drivers/perf/alibaba_uncore_drw_pmu.c +2 -2
@@ -658,8 +658,8 @@ static int ali_drw_pmu_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	drw_pmu->cfg_base = devm_ioremap_resource(&pdev->dev, res);
-	if (!drw_pmu->cfg_base)
-		return -ENOMEM;
+	if (IS_ERR(drw_pmu->cfg_base))
+		return PTR_ERR(drw_pmu->cfg_base);
 
 	name = devm_kasprintf(drw_pmu->dev, GFP_KERNEL, "ali_drw_%llx",
 			      (u64) (res->start >> ALI_DRW_PMU_PA_SHIFT));

Catalin can pick this one up as a fix.

Cheers,

Will

#3 lore raw
In reply to Sun Ke
Quoted 5 lines · Sun Ke

In case of error, devm_ioremap_resource() returns ERR_PTR(), and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR().

Applied to arm64 (for-next/core), thanks!

[1/1] drivers/perf: fix return value check in ali_drw_pmu_probe()

      https://git.kernel.org/arm64/c/ad0112f2d54c
Signature · 1 line
Catalin