aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarl Beldan <karl.beldan+oss@gmail.com>2021-03-17 22:31:58 +0000
committerTom Rini <trini@konsulko.com>2021-04-20 07:31:12 -0400
commit227c53de874b5725f6752e70d40a29f36ca0d2fc (patch)
tree5d2a133bddbc0c7256c22d76d4d35ce998e2fefc /lib
parent0a527fda7821c133ff34132b50e29e2b707db3f0 (diff)
downloadu-boot-227c53de874b5725f6752e70d40a29f36ca0d2fc.zip
u-boot-227c53de874b5725f6752e70d40a29f36ca0d2fc.tar.gz
u-boot-227c53de874b5725f6752e70d40a29f36ca0d2fc.tar.bz2
lz4: Fix unaligned accesses
Signed-off-by: Karl Beldan <karl.beldan+oss@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/lz4_wrapper.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/lz4_wrapper.c b/lib/lz4_wrapper.c
index e0f7d36..cdbcd05 100644
--- a/lib/lz4_wrapper.c
+++ b/lib/lz4_wrapper.c
@@ -11,9 +11,18 @@
#include <linux/types.h>
#include <asm/unaligned.h>
-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;