Re: [Patch] ext4: avoid null dereference

From: Steven Rostedt
Date: Tue Aug 31 2010 - 13:43:32 EST


On Fri, 2010-08-27 at 16:49 +0800, Wen Congyang wrote:
> ac->inode is set to null in function ext4_mb_release_group_pa(),
> and then trace_ext4_mballoc_discard(ac) is called, the kernel
> will panic.

> diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
> index 01e9e00..6a1fcff 100644
> --- a/include/trace/events/ext4.h
> +++ b/include/trace/events/ext4.h
> @@ -796,8 +796,9 @@ DECLARE_EVENT_CLASS(ext4__mballoc,
> ),
>
> TP_fast_assign(
> - __entry->dev = ac->ac_inode->i_sb->s_dev;
> - __entry->ino = ac->ac_inode->i_ino;
> + __entry->dev = ac->ac_sb->s_dev;
> + __entry->ino = ac->ac_inode ?
> + ac->ac_inode->i_ino : 0;

Is i_ino == 0 a valid inode number?

If not, then

Acked-by: Steven Rostedt <rostedt@xxxxxxxxxxx>

-- Steve

> __entry->result_logical = ac->ac_b_ex.fe_logical;
> __entry->result_start = ac->ac_b_ex.fe_start;
> __entry->result_group = ac->ac_b_ex.fe_group;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/