From patchwork Sun Apr 24 03:36:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baidu Boy X-Patchwork-Id: 92632 X-Patchwork-Delegate: dzu@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6C432B6FBE for ; Sun, 24 Apr 2011 13:37:12 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A0BA280C0; Sun, 24 Apr 2011 05:37:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bJXNLUfXyIyx; Sun, 24 Apr 2011 05:37:11 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E565280A9; Sun, 24 Apr 2011 05:37:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D5DAB280A9 for ; Sun, 24 Apr 2011 05:37:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KBfeyzYPZ2NO for ; Sun, 24 Apr 2011 05:37:07 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by theia.denx.de (Postfix) with ESMTPS id D10AF2809E for ; Sun, 24 Apr 2011 05:37:06 +0200 (CEST) Received: by pzk30 with SMTP id 30so920495pzk.3 for ; Sat, 23 Apr 2011 20:37:05 -0700 (PDT) Received: by 10.142.149.14 with SMTP id w14mr1719659wfd.148.1303616225123; Sat, 23 Apr 2011 20:37:05 -0700 (PDT) Received: from LENOVOE5CA6843 ([121.229.190.251]) by mx.google.com with ESMTPS id z10sm5964668wfj.3.2011.04.23.20.36.58 (version=SSLv3 cipher=OTHER); Sat, 23 Apr 2011 20:37:03 -0700 (PDT) From: "Baidu Liu" To: , Date: Sun, 24 Apr 2011 11:36:46 +0800 Message-ID: <001e01cc0230$e0268b90$6401a8c0@LENOVOE5CA6843> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcwCMNY7P2cgPtZiSmm6jzOktNOy5w== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3664 Subject: [U-Boot] [PATCH 3/7] JFFS2: Calculate buf_len before we read data from flash X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 1/ We should calculate the buf_len before we call get_fl_mem(). Signed-off-by: Baidu Liu --- 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;