From patchwork Tue Feb 3 09:02:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 21701 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.176.167]) by ozlabs.org (Postfix) with ESMTP id CA39EDDFA9 for ; Tue, 3 Feb 2009 20:03:24 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750845AbZBCJDW (ORCPT ); Tue, 3 Feb 2009 04:03:22 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750966AbZBCJDW (ORCPT ); Tue, 3 Feb 2009 04:03:22 -0500 Received: from mail-ew0-f21.google.com ([209.85.219.21]:36176 "EHLO mail-ew0-f21.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750845AbZBCJDU (ORCPT ); Tue, 3 Feb 2009 04:03:20 -0500 Received: by ewy14 with SMTP id 14so2292989ewy.13 for ; Tue, 03 Feb 2009 01:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:x-x-sender:to:cc :subject:in-reply-to:message-id:references:user-agent:mime-version :content-type; bh=I/+EJTYr6HnnEGjzROYkJ3XRJSfzVtqV71SZ7E/eLDg=; b=Kzcnb8otTtklkGcs35CLOVxLXoRtpVyvUPgLwJLXVEeGm6v1397hUUy900XX0oWxgf pRvMVNk70tBjgn/O35p4bmVUNaM3SGZUDK0ae0yXN+CpLdTbr7L2+zlu3sI0RDI8WKKK 6Tyfodau1fTYq4pM6IQK9UfVfS1KjbTMcu200= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; b=DYM31D5N1Pf5rDAU4eniFu9VG2fgc5+8AiUOxwwZaqBwPn11PddzeQdBh8ETgJGAOj whFyQlGimU/f1xy+vTnnhGciXIhTKcSTd3vaaH1smg2Z+W9VIeWfJJ2cYfhcGbtzEXPp WKw9hqg4ZOQ8zE9EE7HsnVAGNemzdocIlz5Ig= Received: by 10.210.117.1 with SMTP id p1mr2669665ebc.68.1233651798182; Tue, 03 Feb 2009 01:03:18 -0800 (PST) Received: from bikeee.local ([196.201.153.175]) by mx.google.com with ESMTPS id 28sm1626410eye.39.2009.02.03.01.03.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 03 Feb 2009 01:03:17 -0800 (PST) Date: Tue, 3 Feb 2009 12:02:42 +0300 (EAT) From: Dan Carpenter X-X-Sender: dcarpenter@bikeee To: Andrew Morton cc: Dan Carpenter , sct@redhat.com, linux-ext4@vger.kernel.org, Jan Kara Subject: Re: typo in jbd2_journal_begin_ordered_truncate() In-Reply-To: <20090203003351.1efaa6db.akpm@linux-foundation.org> Message-ID: References: <20090203003351.1efaa6db.akpm@linux-foundation.org> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, 3 Feb 2009, Andrew Morton wrote: > On Tue, 3 Feb 2009 11:23:03 +0300 (EAT) Dan Carpenter wrote: > >> This is jbd2_journal_begin_ordered_truncate() from fs/jbd2/transaction.c. >> >> I think the "&&" is supposed to be an "||" on line 2144. Just knowing >> that inode->i_transaction is NULL should be enough, otherwise we would >> immediately dereference a null on line 2146. >> >> 2144 if (!inode->i_transaction && !inode->i_next_transaction) >> 2145 goto out; >> 2146 journal = inode->i_transaction->t_journal; >> > > Could be. Hard to tell from the code, changelog and (non) comments. Perhaps > it's dead code. > > Send a patch, become famous ;) > > While you're there, rename local var `inode' to `jinode'. > Changed '&&' to '||' to avoid a potential NULL dereference. Also renamed jbd2_inode *inode to jbd2_inode *jinode. regards, dan carpenter Signed-off-by: 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 --- orig/fs/jbd2/transaction.c 2009-02-03 11:49:52.000000000 +0300 +++ devel/fs/jbd2/transaction.c 2009-02-03 11:51:49.000000000 +0300 @@ -2134,21 +2134,21 @@ * case it is in the committing transaction so that we stand to ordered * mode consistency guarantees. */ -int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode, +int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *jinode, loff_t new_size) { journal_t *journal; transaction_t *commit_trans; int ret = 0; - if (!inode->i_transaction && !inode->i_next_transaction) + if (!jinode->i_transaction || !jinode->i_next_transaction) goto out; - journal = inode->i_transaction->t_journal; + journal = jinode->i_transaction->t_journal; spin_lock(&journal->j_state_lock); commit_trans = journal->j_committing_transaction; spin_unlock(&journal->j_state_lock); - if (inode->i_transaction == commit_trans) { - ret = filemap_fdatawrite_range(inode->i_vfs_inode->i_mapping, + if (jinode->i_transaction == commit_trans) { + ret = filemap_fdatawrite_range(jinode->i_vfs_inode->i_mapping, new_size, LLONG_MAX); if (ret) jbd2_journal_abort(journal, ret);