aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/summary.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2/summary.c')
-rw-r--r--fs/jffs2/summary.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index 439b9f6d5837..5dbe87b67ab6 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -399,7 +399,6 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
399 raw = jffs2_alloc_raw_node_ref(); 399 raw = jffs2_alloc_raw_node_ref();
400 if (!raw) { 400 if (!raw) {
401 JFFS2_NOTICE("allocation of node reference failed\n"); 401 JFFS2_NOTICE("allocation of node reference failed\n");
402 kfree(summary);
403 return -ENOMEM; 402 return -ENOMEM;
404 } 403 }
405 404
@@ -407,7 +406,6 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
407 if (!ic) { 406 if (!ic) {
408 JFFS2_NOTICE("scan_make_ino_cache failed\n"); 407 JFFS2_NOTICE("scan_make_ino_cache failed\n");
409 jffs2_free_raw_node_ref(raw); 408 jffs2_free_raw_node_ref(raw);
410 kfree(summary);
411 return -ENOMEM; 409 return -ENOMEM;
412 } 410 }
413 411
@@ -439,10 +437,8 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
439 jeb->offset + je32_to_cpu(spd->offset)); 437 jeb->offset + je32_to_cpu(spd->offset));
440 438
441 fd = jffs2_alloc_full_dirent(spd->nsize+1); 439 fd = jffs2_alloc_full_dirent(spd->nsize+1);
442 if (!fd) { 440 if (!fd)
443 kfree(summary);
444 return -ENOMEM; 441 return -ENOMEM;
445 }
446 442
447 memcpy(&fd->name, spd->name, spd->nsize); 443 memcpy(&fd->name, spd->name, spd->nsize);
448 fd->name[spd->nsize] = 0; 444 fd->name[spd->nsize] = 0;
@@ -451,7 +447,6 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
451 if (!raw) { 447 if (!raw) {
452 jffs2_free_full_dirent(fd); 448 jffs2_free_full_dirent(fd);
453 JFFS2_NOTICE("allocation of node reference failed\n"); 449 JFFS2_NOTICE("allocation of node reference failed\n");
454 kfree(summary);
455 return -ENOMEM; 450 return -ENOMEM;
456 } 451 }
457 452
@@ -459,7 +454,6 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
459 if (!ic) { 454 if (!ic) {
460 jffs2_free_full_dirent(fd); 455 jffs2_free_full_dirent(fd);
461 jffs2_free_raw_node_ref(raw); 456 jffs2_free_raw_node_ref(raw);
462 kfree(summary);
463 return -ENOMEM; 457 return -ENOMEM;
464 } 458 }
465 459
@@ -585,45 +579,28 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
585 default : { 579 default : {
586printk("nodetype = %#04x\n",je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype)); 580printk("nodetype = %#04x\n",je16_to_cpu(((struct jffs2_sum_unknown_flash *)sp)->nodetype));
587 JFFS2_WARNING("Unsupported node type found in summary! Exiting..."); 581 JFFS2_WARNING("Unsupported node type found in summary! Exiting...");
588 kfree(summary);
589 return -EIO; 582 return -EIO;
590 } 583 }
591 } 584 }
592 } 585 }
593 586
594 kfree(summary);
595 return 0; 587 return 0;
596} 588}
597 589
598/* Process the summary node - called from jffs2_scan_eraseblock() */ 590/* Process the summary node - called from jffs2_scan_eraseblock() */
599
600int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, 591int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
601 uint32_t ofs, uint32_t *pseudo_random) 592 struct jffs2_raw_summary *summary, uint32_t sumsize,
593 uint32_t *pseudo_random)
602{ 594{
603 struct jffs2_unknown_node crcnode; 595 struct jffs2_unknown_node crcnode;
604 struct jffs2_raw_node_ref *cache_ref; 596 struct jffs2_raw_node_ref *cache_ref;
605 struct jffs2_raw_summary *summary; 597 int ret, ofs;
606 int ret, sumsize;
607 uint32_t crc; 598 uint32_t crc;
608 599
609 sumsize = c->sector_size - ofs; 600 ofs = jeb->offset + c->sector_size - sumsize;
610 ofs += jeb->offset;
611 601
612 dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n", 602 dbg_summary("summary found for 0x%08x at 0x%08x (0x%x bytes)\n",
613 jeb->offset, ofs, sumsize); 603 jeb->offset, ofs, sumsize);
614
615 summary = kmalloc(sumsize, GFP_KERNEL);
616
617 if (!summary) {
618 return -ENOMEM;
619 }
620
621 ret = jffs2_fill_scan_buf(c, (unsigned char *)summary, ofs, sumsize);
622
623 if (ret) {
624 kfree(summary);
625 return ret;
626 }
627 604
628 /* OK, now check for node validity and CRC */ 605 /* OK, now check for node validity and CRC */
629 crcnode.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 606 crcnode.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -673,7 +650,6 @@ int jffs2_sum_scan_sumnode(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb
673 650
674 if (!marker_ref) { 651 if (!marker_ref) {
675 JFFS2_NOTICE("Failed to allocate node ref for clean marker\n"); 652 JFFS2_NOTICE("Failed to allocate node ref for clean marker\n");
676 kfree(summary);
677 return -ENOMEM; 653 return -ENOMEM;
678 } 654 }
679 655