summaryrefslogtreecommitdiff
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorAlberto Sánchez Molero <alsamolero@gmail.com>2018-01-20 09:17:57 +0200
committerTom Rini <trini@konsulko.com>2018-01-28 12:27:12 -0500
commit2021f083ed634f8233054a6299d95666a933434e (patch)
tree330d2f54df0be9c96509f2f1012964d3f0b89ee2 /fs/btrfs/compression.c
parent990dba649852d79a3ac5f9540a713f6207cf7ea8 (diff)
fs: btrfs: Fix unaligned memory accesses
Loading files stored with lzo compression from a btrfs filesystem was producing unaligned memory accesses, which were causing a data abort and a reset on an Orange Pi Zero. The change in hash.c is not triggered by any error but follows the same pattern. Please confirm. Fixed according to doc/README.unaligned-memory-access.txt Signed-off-by: Alberto Sánchez Molero <alsamolero@gmail.com> Tested-by: Robert Nelson <robertcnelson@gmail.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index a59ff5a8bb..b1b4498fba 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -9,6 +9,7 @@
#include "btrfs.h"
#include <linux/lzo.h>
#include <u-boot/zlib.h>
+#include <asm/unaligned.h>
static u32 decompress_lzo(const u8 *cbuf, u32 clen, u8 *dbuf, u32 dlen)
{
@@ -19,7 +20,7 @@ static u32 decompress_lzo(const u8 *cbuf, u32 clen, u8 *dbuf, u32 dlen)
if (clen < 4)
return -1;
- tot_len = le32_to_cpu(*(u32 *) cbuf);
+ tot_len = le32_to_cpu(get_unaligned((u32 *)cbuf));
cbuf += 4;
clen -= 4;
tot_len -= 4;
@@ -32,7 +33,7 @@ static u32 decompress_lzo(const u8 *cbuf, u32 clen, u8 *dbuf, u32 dlen)
res = 0;
while (tot_len > 4) {
- in_len = le32_to_cpu(*(u32 *) cbuf);
+ in_len = le32_to_cpu(get_unaligned((u32 *)cbuf));
cbuf += 4;
clen -= 4;