[U-Boot] [PATCH 3/7] JFFS2: Calculate buf_len before we read data from flash
Baidu Liu
liucai.lfn at gmail.com
Sun Apr 24 05:36:46 CEST 2011
1/ We should calculate the buf_len before we call
get_fl_mem().
Signed-off-by: Baidu Liu <liucai.lfn at gmail.com>
---
fs/jffs2/jffs2_1pass.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index 8eb77b1..be6ac78 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -1643,6 +1643,8 @@ jffs2_1pass_build_lists(struct part_info * part)
case JFFS2_NODETYPE_INODE:
if (buf_ofs + buf_len < ofs + sizeof(struct
jffs2_raw_inode)) {
+ buf_len = min_t(uint32_t, buf_size, sector_ofs
+ + part->sector_size - ofs);
get_fl_mem((u32)part->offset + ofs,
buf_len, buf);
buf_ofs = ofs;
@@ -1659,11 +1661,11 @@ jffs2_1pass_build_lists(struct part_info * part)
}
break;
case JFFS2_NODETYPE_DIRENT:
- if (buf_ofs + buf_len < ofs + sizeof(struct
- jffs2_raw_dirent) +
- ((struct
- jffs2_raw_dirent *)
- node)->nsize) {
+ if (buf_ofs + buf_len < ofs +
+ sizeof(struct jffs2_raw_dirent) +
+ ((struct jffs2_raw_dirent *)node)->nsize) {
+ buf_len = min_t(uint32_t, buf_size, sector_ofs
+ + part->sector_size - ofs);
get_fl_mem((u32)part->offset + ofs,
buf_len, buf);
buf_ofs = ofs;
--
1.7.3.1.msysgit.0
More information about the U-Boot
mailing list