summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>2026-06-16 18:39:35 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-06-27 11:07:38 +0100
commit4d37e3e1fe9888bccca67df10b86ff0fb2840866 (patch)
tree05799c263c6360850567ccdb37e53958a42be9c2
parentb7611065b40e93fa040221e61bf7e18f0b1848eb (diff)
downloadlinux-stable-4d37e3e1fe9888bccca67df10b86ff0fb2840866.tar.gz
linux-stable-4d37e3e1fe9888bccca67df10b86ff0fb2840866.zip
firmware: exynos-acpm: Count acpm_xfer buffers with __counted_by_ptr
[ Upstream commit 951b8eee0581bbf39e7b0464d679eee8cb9da3e0 ] 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> Stable-dep-of: f133bd4b5daf ("firmware: samsung: acpm: Fix cross-thread RX length corruption") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/firmware/samsung/exynos-acpm-dvfs.c4
-rw-r--r--drivers/firmware/samsung/exynos-acpm.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/firmware/samsung/exynos-acpm-dvfs.c b/drivers/firmware/samsung/exynos-acpm-dvfs.c
index 352a6e64d79d..06bdf62dea1f 100644
--- a/drivers/firmware/samsung/exynos-acpm-dvfs.c
+++ b/drivers/firmware/samsung/exynos-acpm-dvfs.c
@@ -25,12 +25,12 @@ static void acpm_dvfs_set_xfer(struct acpm_xfer *xfer, u32 *cmd, size_t cmdlen,
unsigned int acpm_chan_id, bool response)
{
xfer->acpm_chan_id = acpm_chan_id;
- xfer->txd = cmd;
xfer->txcnt = cmdlen;
+ xfer->txd = cmd;
if (response) {
- xfer->rxd = cmd;
xfer->rxcnt = cmdlen;
+ xfer->rxd = cmd;
}
}
diff --git a/drivers/firmware/samsung/exynos-acpm.h b/drivers/firmware/samsung/exynos-acpm.h
index ac634ef9c678..5df8354dc96c 100644
--- a/drivers/firmware/samsung/exynos-acpm.h
+++ b/drivers/firmware/samsung/exynos-acpm.h
@@ -8,8 +8,8 @@
#define __EXYNOS_ACPM_H__
struct acpm_xfer {
- const u32 *txd;
- u32 *rxd;
+ const u32 *txd __counted_by_ptr(txcnt);
+ u32 *rxd __counted_by_ptr(rxcnt);
size_t txcnt;
size_t rxcnt;
unsigned int acpm_chan_id;