Skip to content

Commit 0834c6f

Browse files
committed
Merge branch 'for-5.18-vsprintf-fourcc-fixup' into for-linus
2 parents b665eae + f74a08f commit 0834c6f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/vsprintf.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
#include <asm/page.h> /* for PAGE_SIZE */
5151
#include <asm/byteorder.h> /* cpu_to_le16 */
52+
#include <asm/unaligned.h>
5253

5354
#include <linux/string_helpers.h>
5455
#include "kstrtox.h"
@@ -1788,29 +1789,31 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
17881789
char output[sizeof("0123 little-endian (0x01234567)")];
17891790
char *p = output;
17901791
unsigned int i;
1791-
u32 val;
1792+
u32 orig, val;
17921793

17931794
if (fmt[1] != 'c' || fmt[2] != 'c')
17941795
return error_string(buf, end, "(%p4?)", spec);
17951796

17961797
if (check_pointer(&buf, end, fourcc, spec))
17971798
return buf;
17981799

1799-
val = *fourcc & ~BIT(31);
1800+
orig = get_unaligned(fourcc);
1801+
val = orig & ~BIT(31);
18001802

1801-
for (i = 0; i < sizeof(*fourcc); i++) {
1803+
for (i = 0; i < sizeof(u32); i++) {
18021804
unsigned char c = val >> (i * 8);
18031805

18041806
/* Print non-control ASCII characters as-is, dot otherwise */
18051807
*p++ = isascii(c) && isprint(c) ? c : '.';
18061808
}
18071809

1808-
strcpy(p, *fourcc & BIT(31) ? " big-endian" : " little-endian");
1810+
*p++ = ' ';
1811+
strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
18091812
p += strlen(p);
18101813

18111814
*p++ = ' ';
18121815
*p++ = '(';
1813-
p = special_hex_number(p, output + sizeof(output) - 2, *fourcc, sizeof(u32));
1816+
p = special_hex_number(p, output + sizeof(output) - 2, orig, sizeof(u32));
18141817
*p++ = ')';
18151818
*p = '\0';
18161819

0 commit comments

Comments
 (0)