Skip to content

Commit 951b8ee

Browse files
committed
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>
1 parent 00808ae commit 951b8ee

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/firmware/samsung/exynos-acpm-dvfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ static void acpm_dvfs_set_xfer(struct acpm_xfer *xfer, u32 *cmd, size_t cmdlen,
2525
unsigned int acpm_chan_id, bool response)
2626
{
2727
xfer->acpm_chan_id = acpm_chan_id;
28-
xfer->txd = cmd;
2928
xfer->txcnt = cmdlen;
29+
xfer->txd = cmd;
3030

3131
if (response) {
32-
xfer->rxd = cmd;
3332
xfer->rxcnt = cmdlen;
33+
xfer->rxd = cmd;
3434
}
3535
}
3636

drivers/firmware/samsung/exynos-acpm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#define __EXYNOS_ACPM_H__
99

1010
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);
1313
size_t txcnt;
1414
size_t rxcnt;
1515
unsigned int acpm_chan_id;

0 commit comments

Comments
 (0)