stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] coresight: trbe: Fix incorrect error check for devm_kzalloc
@ 2025-08-29 12:08 Miaoqian Lin
  2025-09-01  2:09 ` Jie Gan
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2025-08-29 12:08 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin,
	Anshuman Khandual, coresight, linux-arm-kernel, linux-kernel
  Cc: linmq006, stable

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")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/hwtracing/coresight/coresight-trbe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
index 8267dd1a2130..caf873adfc3a 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -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;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] coresight: trbe: Fix incorrect error check for devm_kzalloc
  2025-08-29 12:08 [PATCH] coresight: trbe: Fix incorrect error check for devm_kzalloc Miaoqian Lin
@ 2025-09-01  2:09 ` Jie Gan
  0 siblings, 0 replies; 2+ messages in thread
From: Jie Gan @ 2025-09-01  2:09 UTC (permalink / raw)
  To: Miaoqian Lin, Suzuki K Poulose, Mike Leach, James Clark,
	Alexander Shishkin, Anshuman Khandual, coresight,
	linux-arm-kernel, linux-kernel
  Cc: stable



On 8/29/2025 8:08 PM, Miaoqian Lin wrote:
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>   drivers/hwtracing/coresight/coresight-trbe.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index 8267dd1a2130..caf873adfc3a 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -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

> +	if (!desc.pdata)
>   		goto cpu_clear;
>   
>   	desc.type = CORESIGHT_DEV_TYPE_SINK;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-01  2:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-29 12:08 [PATCH] coresight: trbe: Fix incorrect error check for devm_kzalloc Miaoqian Lin
2025-09-01  2:09 ` Jie Gan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).