From patchwork Fri Oct 26 08:07:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akira Fujita X-Patchwork-Id: 194386 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BA91F2C0097 for ; Fri, 26 Oct 2012 19:14:01 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757295Ab2JZIN6 (ORCPT ); Fri, 26 Oct 2012 04:13:58 -0400 Received: from TYO200.gate.nec.co.jp ([210.143.35.50]:54589 "EHLO tyo200.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757210Ab2JZINz (ORCPT ); Fri, 26 Oct 2012 04:13:55 -0400 X-Greylist: delayed 362 seconds by postgrey-1.27 at vger.kernel.org; Fri, 26 Oct 2012 04:13:55 EDT Received: from tyo202.gate.nec.co.jp ([10.7.69.202]) by tyo200.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id q9Q8DrVE012549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 26 Oct 2012 17:13:53 +0900 (JST) Received: from mailgate3.nec.co.jp ([10.7.69.197]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id q9Q87nB4008649; Fri, 26 Oct 2012 17:07:49 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id q9Q87lg13432; Fri, 26 Oct 2012 17:07:47 +0900 (JST) Received: from mail01b.kamome.nec.co.jp (mail01b.kamome.nec.co.jp [10.25.43.2]) by mailsv.nec.co.jp (8.13.8/8.13.4) with ESMTP id q9Q87h2w026342; Fri, 26 Oct 2012 17:07:43 +0900 (JST) Received: from genzui.jp.nec.com ([10.26.220.13] [10.26.220.13]) by mail03.kamome.nec.co.jp with ESMTP id BT-MMP-2215836; Fri, 26 Oct 2012 17:07:25 +0900 Received: from [10.64.168.93] ([10.64.168.93] [10.64.168.93]) by mail.jp.nec.com with ESMTPA id BT-MMP-54272; Fri, 26 Oct 2012 17:07:25 +0900 Message-ID: <508A44BC.5040002@rs.jp.nec.com> Date: Fri, 26 Oct 2012 17:07:24 +0900 From: Akira Fujita User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: Dan Carpenter CC: linux-ext4@vger.kernel.org Subject: Re: ext4: Replace BUG_ON() with ext4_error() in move_extents.c References: <20121025113503.GA7836@elgon.mountain> In-Reply-To: <20121025113503.GA7836@elgon.mountain> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hello Dan, Thanks for reporting, this patch removes smatch warning. Signed-off-by: Akria Fujita --- fs/ext4/move_extent.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) Regards, Akira Fujita (2012/10/25 20:35), Dan Carpenter wrote: > Hello Akira Fujita, > > This is a semi-automatic email about new static checker warnings. > > The patch 2147b1a6a48e: "ext4: Replace BUG_ON() with ext4_error() in > move_extents.c" from Sep 16, 2009, leads to the following Smatch > complaint: > > fs/ext4/move_extent.c:693 mext_replace_branches() > warn: variable dereferenced before check 'dext' (see line 683) > > fs/ext4/move_extent.c > 682 dext = donor_path[depth].p_ext; > 683 tmp_dext = *dext; > ^^^^^ > Old dereference. > > 684 > 685 *err = mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off, > 686 donor_off, count); > 687 if (*err) > 688 goto out; > 689 > 690 /* Loop for the donor extents */ > 691 while (1) { > 692 /* The extent for donor must be found. */ > 693 if (!dext) { > ^^^^^ > This check was inside BUG_ON() macro before and so Smatch ignored it on > the basis that macros do a lot of unneeded checks. But now it's outside > the macro it triggers a warning. > > 694 EXT4_ERROR_INODE(donor_inode, > 695 "The extent for donor must be found"); > > regards, > dan carpenter > > -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 292daee..17d28a1 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -680,6 +680,10 @@ mext_replace_branches(handle_t *handle, struct inode *orig_inode, depth = ext_depth(donor_inode); dext = donor_path[depth].p_ext; + if (unlikely(!dext)) { + *err = -EIO; + goto out; + } tmp_dext = *dext; *err = mext_calc_swap_extents(&tmp_dext, &tmp_oext, orig_off,