Skip to contentSkip to conversation

Coresight: Fix a NULL vs IS_ERR() bug in probe

PATCH Applied Dan Carpenter 4 participants 4 messages Mar 14, 2025 – Mar 17, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Coresight: Fix a NULL vs IS_ERR() bug in probe

The devm_platform_get_and_ioremap_resource() function doesn't return NULL, it returns error pointers. Update the checking to match.

Fixes f78d206f3d73 ("Coresight: Add Coresight TMC Control Unit driver")
---
 drivers/hwtracing/coresight/coresight-ctcu-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-ctcu-core.c +2 -2
index da35d8b4d579..c6bafc96db96 100644
@@ -204,8 +204,8 @@ static int ctcu_probe(struct platform_device *pdev)
 	dev->platform_data = pdata;
 
 	base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
-	if (!base)
-		return -ENOMEM;
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	drvdata->apb_clk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->apb_clk))
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Dan Carpenter

The devm_platform_get_and_ioremap_resource() function doesn't return NULL, it returns error pointers. Update the checking to match.

Fixes f78d206f3d73 ("Coresight: Add Coresight TMC Control Unit driver")
---
  drivers/hwtracing/coresight/coresight-ctcu-core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-ctcu-core.c +0 -0
index da35d8b4d579..c6bafc96db96 100644

drivers/hwtracing/coresight/coresight-ctcu-core.c static int ctcu_probe(struct platform_device *pdev) · line 211

Quoted 10 lines
drivers/hwtracing/coresight/coresight-ctcu-core.c +2 -2
@@ -204,8 +204,8 @@ static int ctcu_probe(struct platform_device *pdev)
  	dev->platform_data = pdata;
 
  	base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
-	if (!base)
-		return -ENOMEM;
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
  	drvdata->apb_clk = coresight_get_enable_apb_pclk(dev);
  	if (IS_ERR(drvdata->apb_clk))

Thanks for fix it. Looks good to me.

Jie

Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 15 lines · Dan Carpenter

The devm_platform_get_and_ioremap_resource() function doesn't return NULL, it returns error pointers. Update the checking to match.

Fixes f78d206f3d73 ("Coresight: Add Coresight TMC Control Unit driver")
---
 drivers/hwtracing/coresight/coresight-ctcu-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-ctcu-core.c +0 -0
index da35d8b4d579..c6bafc96db96 100644

drivers/hwtracing/coresight/coresight-ctcu-core.c static int ctcu_probe(struct platform_device *pdev) · line 211

Quoted 10 lines
drivers/hwtracing/coresight/coresight-ctcu-core.c +2 -2
@@ -204,8 +204,8 @@ static int ctcu_probe(struct platform_device *pdev)
 	dev->platform_data = pdata;
 
 	base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
-	if (!base)
-		return -ENOMEM;
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	drvdata->apb_clk = coresight_get_enable_apb_pclk(dev);
 	if (IS_ERR(drvdata->apb_clk))
maintainer Applied
#3 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

The devm_platform_get_and_ioremap_resource() function doesn't return NULL, it returns error pointers. Update the checking to match.

Applied, thanks!

[1/1] Coresight: Fix a NULL vs IS_ERR() bug in probe
(no commit info)

Best regards,

Signature · 1 line
Suzuki K Poulose <[email protected]>