diff options
author | Alberto Sánchez Molero <alsamolero@gmail.com> | 2018-01-20 09:17:57 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-01-28 12:27:12 -0500 |
commit | 2021f083ed634f8233054a6299d95666a933434e (patch) | |
tree | 330d2f54df0be9c96509f2f1012964d3f0b89ee2 /fs/btrfs/hash.c | |
parent | 990dba649852d79a3ac5f9540a713f6207cf7ea8 (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/hash.c')
-rw-r--r-- | fs/btrfs/hash.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c index f8a50e532a..cde3abd3df 100644 --- a/fs/btrfs/hash.c +++ b/fs/btrfs/hash.c @@ -8,6 +8,7 @@ #include "btrfs.h" #include <u-boot/crc.h> +#include <asm/unaligned.h> static u32 btrfs_crc32c_table[256]; @@ -34,5 +35,5 @@ u32 btrfs_csum_data(char *data, u32 seed, size_t len) void btrfs_csum_final(u32 crc, void *result) { - *((u32 *) result) = cpu_to_le32(~crc); + put_unaligned(cpu_to_le32(~crc), (u32 *)result); } |