aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2006-06-23 05:05:31 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:43:05 -0400
commit304c4c841a31c780a45d65e389b07706babf5d36 (patch)
treed5fed361a127e46c1a99d72ef907e1c6b03a1abe /fs/jbd
parent22722051fb6bcbb95c895e68dad10d34a9db7e4d (diff)
[PATCH] jbd: avoid kfree(NULL)
There are a couple of places where JBD has to check to see whether an unneeded memory allocation was performed. Usually it _was_ needed, so we end up calling kfree(NULL). We can micro-optimise that by checking the pointer before calling kfree(). Thanks to Steven Rostedt <rostedt@goodmis.org> for identifying this. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/jbd')
-rw-r--r--fs/jbd/transaction.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index ff75afe9b185..508b2ea91f43 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -227,7 +227,8 @@ repeat_locked:
227 spin_unlock(&transaction->t_handle_lock); 227 spin_unlock(&transaction->t_handle_lock);
228 spin_unlock(&journal->j_state_lock); 228 spin_unlock(&journal->j_state_lock);
229out: 229out:
230 kfree(new_transaction); 230 if (unlikely(new_transaction)) /* It's usually NULL */
231 kfree(new_transaction);
231 return ret; 232 return ret;
232} 233}
233 234
@@ -724,7 +725,8 @@ done:
724 journal_cancel_revoke(handle, jh); 725 journal_cancel_revoke(handle, jh);
725 726
726out: 727out:
727 kfree(frozen_buffer); 728 if (unlikely(frozen_buffer)) /* It's usually NULL */
729 kfree(frozen_buffer);
728 730
729 JBUFFER_TRACE(jh, "exit"); 731 JBUFFER_TRACE(jh, "exit");
730 return error; 732 return error;
@@ -903,7 +905,8 @@ repeat:
903 jbd_unlock_bh_state(bh); 905 jbd_unlock_bh_state(bh);
904out: 906out:
905 journal_put_journal_head(jh); 907 journal_put_journal_head(jh);
906 kfree(committed_data); 908 if (unlikely(committed_data))
909 kfree(committed_data);
907 return err; 910 return err;
908} 911}
909 912