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.

firmware: exynos-acpm: Count acpm_xfer buffers with __counted_by_ptr

Use __counted_by_ptr() attribute on the acpm_xfer buffers so UBSAN will
validate runtime that we do not pass over the buffer size, thus making
code safer.

Usage of __counted_by_ptr() (or actually __counted_by()) requires that
counter is initialized before counted array.

Tested-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260219-firmare-acpm-counted-v2-3-e1f7389237d3@oss.qualcomm.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Krzysztof Kozlowski
951b8eee 00808ae2

+4 -4
+2 -2
drivers/firmware/samsung/exynos-acpm-dvfs.c
··· 25 25 unsigned int acpm_chan_id, bool response) 26 26 { 27 27 xfer->acpm_chan_id = acpm_chan_id; 28 - xfer->txd = cmd; 29 28 xfer->txcnt = cmdlen; 29 + xfer->txd = cmd; 30 30 31 31 if (response) { 32 - xfer->rxd = cmd; 33 32 xfer->rxcnt = cmdlen; 33 + xfer->rxd = cmd; 34 34 } 35 35 } 36 36
+2 -2
drivers/firmware/samsung/exynos-acpm.h
··· 8 8 #define __EXYNOS_ACPM_H__ 9 9 10 10 struct acpm_xfer { 11 - const u32 *txd; 12 - u32 *rxd; 11 + const u32 *txd __counted_by_ptr(txcnt); 12 + u32 *rxd __counted_by_ptr(rxcnt); 13 13 size_t txcnt; 14 14 size_t rxcnt; 15 15 unsigned int acpm_chan_id;