On 02/11/2023 08:31, Anshuman Khandual wrote:
On 11/2/23 13:22, Dan Carpenter wrote:
This code was changed from using coresight_get_platform_data() which returns error pointers to devm_kzalloc() which returns NULL. Update the check to match.
Fixes: 4817af577b82 ("coresight: trbe: Add a representative coresight_platform_data for TRBE") Signed-off-by: Dan Carpenter dan.carpenter@linaro.org
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 a3954be7b1f3..228ea85cfc74 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1265,7 +1265,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)
Although this might not be applicable here, given the input size is always valid, devm_kzalloc() might also return ZERO_SIZE_PTR as well.
It will not return ZERO_SIZE_PTR for a non-zero size.
Suzuki
/*
- ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
- Dereferencing ZERO_SIZE_PTR will lead to a distinct access fault.
- ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
- Both make kfree a no-op.
*/ #define ZERO_SIZE_PTR ((void *)16)
#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \ (unsigned long)ZERO_SIZE_PTR)
Hence should ZERO_OR_NULL_PTR() check be used instead ?
goto cpu_clear;
desc.type = CORESIGHT_DEV_TYPE_SINK;