Re: [PATCH tracing/kprobes 2/6] ftrace: Fix trace_add_event_call() to initialize list



On Wed, 2009-09-16 at 10:17 -0400, Masami Hiramatsu wrote:
Steven Rostedt wrote:

diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ba34920..38e82a5 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1009,10 +1009,14 @@ static int __trace_add_event_call(struct ftrace_event_call *call)
if (!d_events)
return -ENOENT;

+ INIT_LIST_HEAD(&call->list);

The INIT_LIST_HEAD is not needed here. The list_add will assign it.

Without initializing it, list debugging code warns always :-)
Please see, __list_add()@lib/list_debug.c

/me looks

from: include/linux/list.h

static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}

from: lib/list_debug.c

void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
WARN(next->prev != prev,
"list_add corruption. next->prev should be "
"prev (%p), but was %p. (next=%p).\n",
prev, next->prev, next);
WARN(prev->next != next,
"list_add corruption. prev->next should be "
"next (%p), but was %p. (prev=%p).\n",
next, prev->next, prev);
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}

What you pass in is:

list_add(&call->list, &ftrace_events);

new = &call->list;
prev = &ftrace_events->prev;
next = &ftrace_events->next;

The above code never tests "new". The INIT_LIST_HEAD is useless.

-- Steve


--
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/



Relevant Pages

  • Re: [BUG] CFS vs cpu hotplug
    ... I'm still seeing kernel crashes on cpu hotplug with Linus' current git tree. ... tasks_timeline = struct rb_root { ... prev = 0x759328 ... balance_iterator = (nil) ...
    (Linux-Kernel)
  • [BUG] CFS vs cpu hotplug
    ... I'm still seeing kernel crashes on cpu hotplug with Linus' current git tree. ... tasks_timeline = struct rb_root { ... prev = 0x759328 ... balance_iterator = (nil) ...
    (Linux-Kernel)
  • Re: Linux 2.6.32.19
    ... +static inline int s390_nohz_delay ... unsigned long prev; ... struct irq_desc *desc; ... return ret; ...
    (Linux-Kernel)
  • Re: [PATCH] ftrace: add an fsync tracer
    ... TPPROTO(struct rq *rq, struct task_struct *prev, ... markers, or by tracepoints converted to markers, or by tracepoints ...
    (Linux-Kernel)
  • Re: [PATCH 2/9] swap_info: change to array of pointers
    ... struct swap_info_struct { ... static int ... offset = swp_offset; ... prev = -1; ...
    (Linux-Kernel)