From: Dan Carpenter <error27@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Carpenter <error27@gmail.com>,
sct@redhat.com, linux-ext4@vger.kernel.org,
Jan Kara <jack@suse.cz>
Subject: Re: typo in jbd2_journal_begin_ordered_truncate()
Date: Tue, 3 Feb 2009 12:02:42 +0300 (EAT) [thread overview]
Message-ID: <alpine.DEB.2.00.0902031156320.2929@bikeee> (raw)
In-Reply-To: <20090203003351.1efaa6db.akpm@linux-foundation.org>
On Tue, 3 Feb 2009, Andrew Morton wrote:
> On Tue, 3 Feb 2009 11:23:03 +0300 (EAT) Dan Carpenter <error27@gmail.com> 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 <error27@gmail.com>
--- 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);
next prev parent reply other threads:[~2009-02-03 9:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 8:23 typo in jbd2_journal_begin_ordered_truncate() Dan Carpenter
2009-02-03 8:33 ` Andrew Morton
2009-02-03 9:02 ` Dan Carpenter [this message]
2009-02-03 14:23 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.0902031156320.2929@bikeee \
--to=error27@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=sct@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox