* [merged] lib-fix-the-use-of-lzo-to-decompress-initramfs-images.patch removed from -mm tree
@ 2010-04-26 14:26 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2010-04-26 14:26 UTC (permalink / raw)
To: albin.tonnerre, hpa, spambemyguest, mm-commits
The patch titled
lib: fix the use of LZO to decompress initramfs images
has been removed from the -mm tree. Its filename was
lib-fix-the-use-of-lzo-to-decompress-initramfs-images.patch
This patch was dropped because it was merged into mainline or a subsystem tree
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: lib: fix the use of LZO to decompress initramfs images
From: Albin Tonnerre <albin.tonnerre@free-electrons.com>
This patch fixes 2 issues with the LZO decompressor:
- It doesn't handle the case where a block isn't compressed at all. In
this case, calling lzo1x_decompress_safe will fail, so we need to just
use memcpy() instead (the upstream LZO code does something similar)
- Since commit 54291362d2a5738e1b0495df2abcb9e6b0563a3f ("initramfs: add
missing decompressor error check") , the decompressor return code is
checked in the init/initramfs.c The LZO decompressor didn't return the
expected value, causing the initramfs code to falsely believe a
decompression error occured
Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Tested-by: bert schulze <spambemyguest@googlemail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/decompress_unlzo.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff -puN lib/decompress_unlzo.c~lib-fix-the-use-of-lzo-to-decompress-initramfs-images lib/decompress_unlzo.c
--- a/lib/decompress_unlzo.c~lib-fix-the-use-of-lzo-to-decompress-initramfs-images
+++ a/lib/decompress_unlzo.c
@@ -97,7 +97,7 @@ STATIC inline int INIT unlzo(u8 *input,
u32 src_len, dst_len;
size_t tmp;
u8 *in_buf, *in_buf_save, *out_buf;
- int obytes_processed = 0;
+ int ret = -1;
set_error_fn(error_fn);
@@ -174,15 +174,22 @@ STATIC inline int INIT unlzo(u8 *input,
/* decompress */
tmp = dst_len;
- r = lzo1x_decompress_safe((u8 *) in_buf, src_len,
+
+ /* When the input data is not compressed at all,
+ * lzo1x_decompress_safe will fail, so call memcpy()
+ * instead */
+ if (unlikely(dst_len == src_len))
+ memcpy(out_buf, in_buf, src_len);
+ else {
+ r = lzo1x_decompress_safe((u8 *) in_buf, src_len,
out_buf, &tmp);
- if (r != LZO_E_OK || dst_len != tmp) {
- error("Compressed data violation");
- goto exit_2;
+ if (r != LZO_E_OK || dst_len != tmp) {
+ error("Compressed data violation");
+ goto exit_2;
+ }
}
- obytes_processed += dst_len;
if (flush)
flush(out_buf, dst_len);
if (output)
@@ -196,6 +203,7 @@ STATIC inline int INIT unlzo(u8 *input,
in_buf += src_len;
}
+ ret = 0;
exit_2:
if (!input)
free(in_buf);
@@ -203,7 +211,7 @@ exit_1:
if (!output)
free(out_buf);
exit:
- return obytes_processed;
+ return ret;
}
#define decompress unlzo
_
Patches currently in -mm which might be from albin.tonnerre@free-electrons.com are
origin.patch
linux-next.patch
initramfs-add-support-for-in-kernel-initramfs-compressed-with-lzo.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-04-26 17:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26 14:26 [merged] lib-fix-the-use-of-lzo-to-decompress-initramfs-images.patch removed from -mm tree akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox