From 4d4b3a4efe1aa248369d33f725273f37d6071448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Sat, 14 Jun 2025 21:45:29 +0200 Subject: [PATCH] drivers: hwinfo: litex: fix device ID calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `end` variable should be calculated based on the device's register size, not the address. Probably never caught before as user typically provides a buffer of reasonable size... Signed-off-by: Benjamin Cabé --- drivers/hwinfo/hwinfo_litex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwinfo/hwinfo_litex.c b/drivers/hwinfo/hwinfo_litex.c index f354feed7a0..fd0145e0924 100644 --- a/drivers/hwinfo/hwinfo_litex.c +++ b/drivers/hwinfo/hwinfo_litex.c @@ -15,7 +15,7 @@ ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) { uint32_t addr = DT_INST_REG_ADDR(0); - ssize_t end = MIN(length, DT_INST_REG_ADDR(0) / 4 * + ssize_t end = MIN(length, DT_INST_REG_SIZE(0) / 4 * CONFIG_LITEX_CSR_DATA_WIDTH / 8); for (int i = 0; i < end; i++) { #if CONFIG_LITEX_CSR_DATA_WIDTH == 8