* [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu()
@ 2024-10-18 14:08 Zhen Lei
2024-10-18 16:02 ` James Clark
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zhen Lei @ 2024-10-18 14:08 UTC (permalink / raw)
To: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin,
Mathieu Poirier, Anshuman Khandual, coresight, linux-arm-kernel,
linux-kernel
Cc: Zhen Lei
Function devm_kzalloc() returns NULL instead of ERR_PTR() when it fails.
The IS_ERR() test in the return value check should be replaced with NULL
test.
Fixes: 39744738a67d ("coresight: trbe: Allocate platform data per device")
Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.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 96a32b213669940..93fe9860acf16bd 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -1266,7 +1266,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.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu()
2024-10-18 14:08 [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu() Zhen Lei
@ 2024-10-18 16:02 ` James Clark
2024-10-18 16:26 ` [PATCH] " Markus Elfring
2024-10-21 2:58 ` [PATCH 1/1] " Anshuman Khandual
2 siblings, 0 replies; 5+ messages in thread
From: James Clark @ 2024-10-18 16:02 UTC (permalink / raw)
To: Zhen Lei, Suzuki K Poulose
Cc: Mike Leach, Alexander Shishkin, Mathieu Poirier,
Anshuman Khandual, coresight, linux-arm-kernel, linux-kernel
On 18/10/2024 3:08 pm, Zhen Lei wrote:
> Function devm_kzalloc() returns NULL instead of ERR_PTR() when it fails.
> The IS_ERR() test in the return value check should be replaced with NULL
> test.
>
> Fixes: 39744738a67d ("coresight: trbe: Allocate platform data per device")
> Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver")
I don't think the code that this patches exists in 3fbf7f011f24, but it
looks ok for 39744738a67d.
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.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 96a32b213669940..93fe9860acf16bd 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -1266,7 +1266,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;
Reviewed-by: James Clark <james.clark@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu()
2024-10-18 14:08 [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu() Zhen Lei
2024-10-18 16:02 ` James Clark
@ 2024-10-18 16:26 ` Markus Elfring
2024-10-21 2:58 ` [PATCH 1/1] " Anshuman Khandual
2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2024-10-18 16:26 UTC (permalink / raw)
To: Zhen Lei, coresight, linux-arm-kernel, Alexander Shishkin,
Anshuman Khandual, James Clark, Mathieu Poirier, Mike Leach,
Suzuki Poulouse
Cc: LKML
…
> The IS_ERR() test in the return value check should be replaced with NULL test.
…
How do you think about to convert such a change description into
an imperative wording?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc3#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu()
2024-10-18 14:08 [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu() Zhen Lei
2024-10-18 16:02 ` James Clark
2024-10-18 16:26 ` [PATCH] " Markus Elfring
@ 2024-10-21 2:58 ` Anshuman Khandual
2024-10-21 3:57 ` Leizhen (ThunderTown)
2 siblings, 1 reply; 5+ messages in thread
From: Anshuman Khandual @ 2024-10-21 2:58 UTC (permalink / raw)
To: Zhen Lei, Suzuki K Poulose, Mike Leach, James Clark,
Alexander Shishkin, Mathieu Poirier, coresight, linux-arm-kernel,
linux-kernel
On 10/18/24 19:38, Zhen Lei wrote:
> Function devm_kzalloc() returns NULL instead of ERR_PTR() when it fails.
Right, devm_kzalloc() calls devm_kmalloc() with additional __GFP_ZERO which
returns NULL on error.
> The IS_ERR() test in the return value check should be replaced with NULL
> test.
>
> Fixes: 39744738a67d ("coresight: trbe: Allocate platform data per device")
> Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver")
Actually this problem is caused by the following commit which had replaced
coresight_get_platform_data() with devm_kzalloc() for a dummy 'desc.pdata'
allocation. Earlier IS_ERR() test for the return value, was correct for
coresight_get_platform_data() which returns ERR_PTR() on error, but then
it should have been changed for devm_kzalloc() into a NULL check instead.
4277f035d227 ("coresight: trbe: Add a representative coresight_platform_data for TRBE")
Please add "Fixes:" tag for the above commit instead.
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.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 96a32b213669940..93fe9860acf16bd 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -1266,7 +1266,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;
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu()
2024-10-21 2:58 ` [PATCH 1/1] " Anshuman Khandual
@ 2024-10-21 3:57 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 5+ messages in thread
From: Leizhen (ThunderTown) @ 2024-10-21 3:57 UTC (permalink / raw)
To: Anshuman Khandual, Suzuki K Poulose, Mike Leach, James Clark,
Alexander Shishkin, Mathieu Poirier, coresight, linux-arm-kernel,
linux-kernel
On 2024/10/21 10:58, Anshuman Khandual wrote:
>
>
> On 10/18/24 19:38, Zhen Lei wrote:
>> Function devm_kzalloc() returns NULL instead of ERR_PTR() when it fails.
>
> Right, devm_kzalloc() calls devm_kmalloc() with additional __GFP_ZERO which
> returns NULL on error.
>
>> The IS_ERR() test in the return value check should be replaced with NULL
>> test.
>>
>> Fixes: 39744738a67d ("coresight: trbe: Allocate platform data per device")
>> Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver")
>
> Actually this problem is caused by the following commit which had replaced
> coresight_get_platform_data() with devm_kzalloc() for a dummy 'desc.pdata'
> allocation. Earlier IS_ERR() test for the return value, was correct for
> coresight_get_platform_data() which returns ERR_PTR() on error, but then
> it should have been changed for devm_kzalloc() into a NULL check instead.
>
> 4277f035d227 ("coresight: trbe: Add a representative coresight_platform_data for TRBE")
>
> Please add "Fixes:" tag for the above commit instead.
Yes, you're right. In retrospect, I probably found 3fbf7f011f24 just by
searching for IS_ERR(). I will update and post v2. Thanks.
>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.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 96a32b213669940..93fe9860acf16bd 100644
>> --- a/drivers/hwtracing/coresight/coresight-trbe.c
>> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
>> @@ -1266,7 +1266,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;
>
> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
>
> .
>
--
Regards,
Zhen Lei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-21 3:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-18 14:08 [PATCH 1/1] coresight: trbe: Fix return value check in arm_trbe_register_coresight_cpu() Zhen Lei
2024-10-18 16:02 ` James Clark
2024-10-18 16:26 ` [PATCH] " Markus Elfring
2024-10-21 2:58 ` [PATCH 1/1] " Anshuman Khandual
2024-10-21 3:57 ` Leizhen (ThunderTown)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®