Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 3fbf7f011f24 ("coresight: sink: Add TRBE driver")
Reported-by: Tamas Zsoldos <tamas.zsoldos@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20250904-cs_etm_auxsetup_fix_error_handling-v2-1-a502d0bafb95@arm.com

authored by

Leo Yan and committed by
Suzuki K Poulose
8a55c161 dc783892

+3 -3
+3 -3
drivers/hwtracing/coresight/coresight-trbe.c
··· 748 748 749 749 buf = kzalloc_node(sizeof(*buf), GFP_KERNEL, trbe_alloc_node(event)); 750 750 if (!buf) 751 - return ERR_PTR(-ENOMEM); 751 + return NULL; 752 752 753 753 pglist = kcalloc(nr_pages, sizeof(*pglist), GFP_KERNEL); 754 754 if (!pglist) { 755 755 kfree(buf); 756 - return ERR_PTR(-ENOMEM); 756 + return NULL; 757 757 } 758 758 759 759 for (i = 0; i < nr_pages; i++) ··· 763 763 if (!buf->trbe_base) { 764 764 kfree(pglist); 765 765 kfree(buf); 766 - return ERR_PTR(-ENOMEM); 766 + return NULL; 767 767 } 768 768 buf->trbe_limit = buf->trbe_base + nr_pages * PAGE_SIZE; 769 769 buf->trbe_write = buf->trbe_base;