Skip to content

Commit

Permalink
lib/lzo/lzo1x_compress.c: fix alignment bug in lzo-rle
Browse files Browse the repository at this point in the history
Fix an unaligned access which breaks on platforms where this is not
permitted (e.g., Sparc).

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Dave Rodgman <[email protected]>
Cc: Dave Rodgman <[email protected]>
Cc: Markus F.X.J. Oberhumer <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
daverodgman authored and torvalds committed Sep 26, 2019
1 parent 984035a commit 09b35b4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/lzo/lzo1x_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,19 @@ lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
ALIGN((uintptr_t)ir, 4)) &&
(ir < limit) && (*ir == 0))
ir++;
for (; (ir + 4) <= limit; ir += 4) {
dv = *((u32 *)ir);
if (dv) {
if (IS_ALIGNED((uintptr_t)ir, 4)) {
for (; (ir + 4) <= limit; ir += 4) {
dv = *((u32 *)ir);
if (dv) {
# if defined(__LITTLE_ENDIAN)
ir += __builtin_ctz(dv) >> 3;
ir += __builtin_ctz(dv) >> 3;
# elif defined(__BIG_ENDIAN)
ir += __builtin_clz(dv) >> 3;
ir += __builtin_clz(dv) >> 3;
# else
# error "missing endian definition"
# endif
break;
break;
}
}
}
#endif
Expand Down

0 comments on commit 09b35b4

Please sign in to comment.