ext4: fix potential NULL dereference while tracing
authorTheodore Ts'o <tytso@mit.edu>
Tue, 27 Jul 2010 15:56:04 +0000 (11:56 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 27 Jul 2010 15:56:04 +0000 (11:56 -0400)
The allocation_context pointer can be NULL.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/mballoc.c
include/trace/events/ext4.h

index 3dfad95f0f9889fde6d9cdfcd0bdd0ad6e5af15b..8b3b9344a595828bb8c0e8ed53cf92696ffb6dc4 100644 (file)
@@ -3575,7 +3575,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
                        trace_ext4_mballoc_discard(ac);
                }
 
-               trace_ext4_mb_release_inode_pa(ac, pa, grp_blk_start + bit,
+               trace_ext4_mb_release_inode_pa(sb, ac, pa, grp_blk_start + bit,
                                               next - bit);
                mb_free_blocks(pa->pa_inode, e4b, bit, next - bit);
                bit = next + 1;
@@ -3606,7 +3606,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
        ext4_group_t group;
        ext4_grpblk_t bit;
 
-       trace_ext4_mb_release_group_pa(ac, pa);
+       trace_ext4_mb_release_group_pa(sb, ac, pa);
        BUG_ON(pa->pa_deleted == 0);
        ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
        BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
index f3865c7b4166e315da77d9c342b977b9d4338915..01e9e0076a92c68682fa513e1f4a862e291fb9ae 100644 (file)
@@ -395,11 +395,12 @@ DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa,
 );
 
 TRACE_EVENT(ext4_mb_release_inode_pa,
-       TP_PROTO(struct ext4_allocation_context *ac,
+       TP_PROTO(struct super_block *sb,
+                struct ext4_allocation_context *ac,
                 struct ext4_prealloc_space *pa,
                 unsigned long long block, unsigned int count),
 
-       TP_ARGS(ac, pa, block, count),
+       TP_ARGS(sb, ac, pa, block, count),
 
        TP_STRUCT__entry(
                __field(        dev_t,  dev                     )
@@ -410,8 +411,9 @@ TRACE_EVENT(ext4_mb_release_inode_pa,
        ),
 
        TP_fast_assign(
-               __entry->dev            = ac->ac_sb->s_dev;
-               __entry->ino            = ac->ac_inode->i_ino;
+               __entry->dev            = sb->s_dev;
+               __entry->ino            = (ac && ac->ac_inode) ? 
+                                               ac->ac_inode->i_ino : 0;
                __entry->block          = block;
                __entry->count          = count;
        ),
@@ -422,10 +424,11 @@ TRACE_EVENT(ext4_mb_release_inode_pa,
 );
 
 TRACE_EVENT(ext4_mb_release_group_pa,
-       TP_PROTO(struct ext4_allocation_context *ac,
+       TP_PROTO(struct super_block *sb,
+                struct ext4_allocation_context *ac,
                 struct ext4_prealloc_space *pa),
 
-       TP_ARGS(ac, pa),
+       TP_ARGS(sb, ac, pa),
 
        TP_STRUCT__entry(
                __field(        dev_t,  dev                     )
@@ -436,8 +439,9 @@ TRACE_EVENT(ext4_mb_release_group_pa,
        ),
 
        TP_fast_assign(
-               __entry->dev            = ac->ac_sb->s_dev;
-               __entry->ino            = ac->ac_inode->i_ino;
+               __entry->dev            = sb->s_dev;
+               __entry->ino            = (ac && ac->ac_inode) ?
+                                               ac->ac_inode->i_ino : 0;
                __entry->pa_pstart      = pa->pa_pstart;
                __entry->pa_len         = pa->pa_len;
        ),