Skip to contentSkip to conversation

coresight: trbe: Fix incorrect error check for devm_kzalloc

PATCH In review Miaoqian Lin 2 participants 2 messages Aug 29, 2025 – Sep 1, 2025

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

PATCH 1/1 coresight: trbe: Fix incorrect error check for devm_kzalloc

Fix incorrect use of IS_ERR() to check devm_kzalloc() return value. devm_kzalloc() returns NULL on failure, not an error pointer.

This issue was introduced by commit 4277f035d227
("coresight: trbe: Add a representative coresight_platform_data for TRBE") which replaced the original function but didn't update the error check.

Fixes 4277f035d227 ("coresight: trbe: Add a representative coresight_platform_data for TRBE")
---
 drivers/hwtracing/coresight/coresight-trbe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-trbe.c +1 -1
index 8267dd1a2130..caf873adfc3a 100644
@@ -1279,7 +1279,7 @@ static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cp
 	 * into the device for that purpose.
 	 */
 	desc.pdata = devm_kzalloc(dev, sizeof(*desc.pdata), GFP_KERNEL);
-	if (IS_ERR(desc.pdata))
+	if (!desc.pdata)
 		goto cpu_clear;
 
 	desc.type = CORESIGHT_DEV_TYPE_SINK;
Signature · 1 line
2.35.1
#1 lore raw
Quoted 19 lines · Miaoqian Lin

Fix incorrect use of IS_ERR() to check devm_kzalloc() return value. devm_kzalloc() returns NULL on failure, not an error pointer.

This issue was introduced by commit 4277f035d227
("coresight: trbe: Add a representative coresight_platform_data for TRBE") which replaced the original function but didn't update the error check.

Fixes 4277f035d227 ("coresight: trbe: Add a representative coresight_platform_data for TRBE")
---
  drivers/hwtracing/coresight/coresight-trbe.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-trbe.c +0 -0
index 8267dd1a2130..caf873adfc3a 100644

drivers/hwtracing/coresight/coresight-trbe.c static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cp · line 1282

Quoted 4 lines
drivers/hwtracing/coresight/coresight-trbe.c +0 -1
@@ -1279,7 +1279,7 @@ static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cp
  	 * into the device for that purpose.
  	 */
  	desc.pdata = devm_kzalloc(dev, sizeof(*desc.pdata), GFP_KERNEL);
-	if (IS_ERR(desc.pdata))

IS_ERR_OR_NULL(desc.pdata) would be better.

Thanks,
Jie

Quoted 4 lines
drivers/hwtracing/coresight/coresight-trbe.c +1 -0
+	if (!desc.pdata)
  		goto cpu_clear;
 
  	desc.type = CORESIGHT_DEV_TYPE_SINK;