diff options
Diffstat (limited to 'init/initramfs.c')
-rw-r--r-- | init/initramfs.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/init/initramfs.c b/init/initramfs.c index 4c00edc59689..4b9c20205092 100644 --- a/init/initramfs.c +++ b/init/initramfs.c | |||
@@ -413,7 +413,7 @@ static unsigned my_inptr; /* index of next byte to be processed in inbuf */ | |||
413 | 413 | ||
414 | static char * __init unpack_to_rootfs(char *buf, unsigned len) | 414 | static char * __init unpack_to_rootfs(char *buf, unsigned len) |
415 | { | 415 | { |
416 | int written; | 416 | int written, res; |
417 | decompress_fn decompress; | 417 | decompress_fn decompress; |
418 | const char *compress_name; | 418 | const char *compress_name; |
419 | static __initdata char msg_buf[64]; | 419 | static __initdata char msg_buf[64]; |
@@ -445,17 +445,20 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len) | |||
445 | } | 445 | } |
446 | this_header = 0; | 446 | this_header = 0; |
447 | decompress = decompress_method(buf, len, &compress_name); | 447 | decompress = decompress_method(buf, len, &compress_name); |
448 | if (decompress) | 448 | if (decompress) { |
449 | decompress(buf, len, NULL, flush_buffer, NULL, | 449 | res = decompress(buf, len, NULL, flush_buffer, NULL, |
450 | &my_inptr, error); | 450 | &my_inptr, error); |
451 | else if (compress_name) { | 451 | if (res) |
452 | error("decompressor failed"); | ||
453 | } else if (compress_name) { | ||
452 | if (!message) { | 454 | if (!message) { |
453 | snprintf(msg_buf, sizeof msg_buf, | 455 | snprintf(msg_buf, sizeof msg_buf, |
454 | "compression method %s not configured", | 456 | "compression method %s not configured", |
455 | compress_name); | 457 | compress_name); |
456 | message = msg_buf; | 458 | message = msg_buf; |
457 | } | 459 | } |
458 | } | 460 | } else |
461 | error("junk in compressed archive"); | ||
459 | if (state != Reset) | 462 | if (state != Reset) |
460 | error("junk in compressed archive"); | 463 | error("junk in compressed archive"); |
461 | this_header = saved_offset + my_inptr; | 464 | this_header = saved_offset + my_inptr; |
@@ -523,7 +526,7 @@ static void __init clean_rootfs(void) | |||
523 | int fd; | 526 | int fd; |
524 | void *buf; | 527 | void *buf; |
525 | struct linux_dirent64 *dirp; | 528 | struct linux_dirent64 *dirp; |
526 | int count; | 529 | int num; |
527 | 530 | ||
528 | fd = sys_open("/", O_RDONLY, 0); | 531 | fd = sys_open("/", O_RDONLY, 0); |
529 | WARN_ON(fd < 0); | 532 | WARN_ON(fd < 0); |
@@ -537,9 +540,9 @@ static void __init clean_rootfs(void) | |||
537 | } | 540 | } |
538 | 541 | ||
539 | dirp = buf; | 542 | dirp = buf; |
540 | count = sys_getdents64(fd, dirp, BUF_SIZE); | 543 | num = sys_getdents64(fd, dirp, BUF_SIZE); |
541 | while (count > 0) { | 544 | while (num > 0) { |
542 | while (count > 0) { | 545 | while (num > 0) { |
543 | struct stat st; | 546 | struct stat st; |
544 | int ret; | 547 | int ret; |
545 | 548 | ||
@@ -552,12 +555,12 @@ static void __init clean_rootfs(void) | |||
552 | sys_unlink(dirp->d_name); | 555 | sys_unlink(dirp->d_name); |
553 | } | 556 | } |
554 | 557 | ||
555 | count -= dirp->d_reclen; | 558 | num -= dirp->d_reclen; |
556 | dirp = (void *)dirp + dirp->d_reclen; | 559 | dirp = (void *)dirp + dirp->d_reclen; |
557 | } | 560 | } |
558 | dirp = buf; | 561 | dirp = buf; |
559 | memset(buf, 0, BUF_SIZE); | 562 | memset(buf, 0, BUF_SIZE); |
560 | count = sys_getdents64(fd, dirp, BUF_SIZE); | 563 | num = sys_getdents64(fd, dirp, BUF_SIZE); |
561 | } | 564 | } |
562 | 565 | ||
563 | sys_close(fd); | 566 | sys_close(fd); |