generic: platform/mikrotik: fix routerboot_tag_show_u32s()
authorThibaut VARÈNE <hacks@slashdirt.org>
Fri, 5 Jun 2020 11:59:41 +0000 (13:59 +0200)
committerPetr Štetiar <ynezz@true.cz>
Wed, 8 Jul 2020 14:07:05 +0000 (16:07 +0200)
The routine would only accurately print out the first word.

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
Fixes: 5ecf7d96 ("generic: routerboot sysfs platform driver")
target/linux/generic/files/drivers/platform/mikrotik/routerboot.c

index 47e4471f8e3108d8b9d04a1b465a1b8cfa44c382..4c8c0bfac582a5799af4ee6b67c0c154a8886f41 100644 (file)
@@ -194,18 +194,18 @@ ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf)
 ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf)
 {
        char *out = buf;
-       u32 data;       // cpu-endian
+       u32 *data;      // cpu-endian
 
        /* Caller ensures pld_len > 0 */
-       if (pld_len % sizeof(data))
+       if (pld_len % sizeof(*data))
                return -EINVAL;
 
-       data = *(u32 *)pld;
+       data = (u32 *)pld;
 
        do {
-               out += sprintf(out, "0x%08x\n", data);
+               out += sprintf(out, "0x%08x\n", *data);
                data++;
-       } while ((pld_len -= sizeof(data)));
+       } while ((pld_len -= sizeof(*data)));
 
        return out - buf;
 }