[Pdbg] [PATCH v1] sbefifo: fix sbefifo_register_get with multiple registers
Nicholas Piggin
npiggin at gmail.com
Fri Nov 12 18:10:25 AEDT 2021
sbefifo_register_get_pull is not indexing the result buffer correctly
for > 1 returned register.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
libsbefifo/cmd_register.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libsbefifo/cmd_register.c b/libsbefifo/cmd_register.c
index 6c3f336..1e74b6e 100644
--- a/libsbefifo/cmd_register.c
+++ b/libsbefifo/cmd_register.c
@@ -57,6 +57,7 @@ static int sbefifo_register_get_push(uint8_t core_id, uint8_t thread_id, uint8_t
static int sbefifo_register_get_pull(uint8_t *buf, uint32_t buflen, uint8_t reg_count, uint64_t **value)
{
uint32_t i;
+ uint32_t *b = (uint32_t *)buf;
if (buflen != reg_count * 8)
return EPROTO;
@@ -68,8 +69,8 @@ static int sbefifo_register_get_pull(uint8_t *buf, uint32_t buflen, uint8_t reg_
for (i=0; i<reg_count; i++) {
uint32_t val1, val2;
- val1 = be32toh(*(uint32_t *) &buf[i*4]);
- val2 = be32toh(*(uint32_t *) &buf[i*4+4]);
+ val1 = be32toh(b[i*2]);
+ val2 = be32toh(b[i*2+1]);
(*value)[i] = ((uint64_t)val1 << 32) | (uint64_t)val2;
}
--
2.23.0
More information about the Pdbg
mailing list