From 227c53de874b5725f6752e70d40a29f36ca0d2fc Mon Sep 17 00:00:00 2001 From: Karl Beldan Date: Wed, 17 Mar 2021 22:31:58 +0000 Subject: lz4: Fix unaligned accesses Signed-off-by: Karl Beldan --- lib/lz4_wrapper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/lz4_wrapper.c') diff --git a/lib/lz4_wrapper.c b/lib/lz4_wrapper.c index e0f7d3688ee..cdbcd05bd43 100644 --- a/lib/lz4_wrapper.c +++ b/lib/lz4_wrapper.c @@ -11,9 +11,18 @@ #include #include -static u16 LZ4_readLE16(const void *src) { return le16_to_cpu(*(u16 *)src); } -static void LZ4_copy4(void *dst, const void *src) { *(u32 *)dst = *(u32 *)src; } -static void LZ4_copy8(void *dst, const void *src) { *(u64 *)dst = *(u64 *)src; } +static u16 LZ4_readLE16(const void *src) +{ + return get_unaligned_le16(src); +} +static void LZ4_copy4(void *dst, const void *src) +{ + put_unaligned(get_unaligned((const u32 *)src), (u32 *)dst); +} +static void LZ4_copy8(void *dst, const void *src) +{ + put_unaligned(get_unaligned((const u64 *)src), (u64 *)dst); +} typedef uint8_t BYTE; typedef uint16_t U16; -- cgit v1.2.3