Skip to content

Commit 8a55c16

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: trbe: Return NULL pointer for allocation failures
When the TRBE driver fails to allocate a buffer, it currently returns the error code "-ENOMEM". However, the caller etm_setup_aux() only checks for a NULL pointer, so it misses the error. As a result, the driver continues and eventually causes a kernel panic. Fix this by returning a NULL pointer from arm_trbe_alloc_buffer() on allocation failures. This allows that the callers can properly handle the failure. Fixes: 3fbf7f0 ("coresight: sink: Add TRBE driver") Reported-by: Tamas Zsoldos <[email protected]> Signed-off-by: Leo Yan <[email protected]> Reviewed-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/20250904-cs_etm_auxsetup_fix_error_handling-v2-1-a502d0bafb95@arm.com
1 parent dc78389 commit 8a55c16

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/hwtracing/coresight/coresight-trbe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,12 +748,12 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev,
748748

749749
buf = kzalloc_node(sizeof(*buf), GFP_KERNEL, trbe_alloc_node(event));
750750
if (!buf)
751-
return ERR_PTR(-ENOMEM);
751+
return NULL;
752752

753753
pglist = kcalloc(nr_pages, sizeof(*pglist), GFP_KERNEL);
754754
if (!pglist) {
755755
kfree(buf);
756-
return ERR_PTR(-ENOMEM);
756+
return NULL;
757757
}
758758

759759
for (i = 0; i < nr_pages; i++)
@@ -763,7 +763,7 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev,
763763
if (!buf->trbe_base) {
764764
kfree(pglist);
765765
kfree(buf);
766-
return ERR_PTR(-ENOMEM);
766+
return NULL;
767767
}
768768
buf->trbe_limit = buf->trbe_base + nr_pages * PAGE_SIZE;
769769
buf->trbe_write = buf->trbe_base;

0 commit comments

Comments
 (0)