Skip to content

Commit a54665a

Browse files
committed
ftrace: Comment that ftrace_func_mapper is freed with free_ftrace_hash()
The structure ftrace_func_mapper only contains a single field and that is a ftrace_hash. It is used to abstract it out from a normal hash to control users of how it gets modified. The freeing of a ftrace_func_mapper structure is: free_ftrace_hash(&mapper->hash); Without context, this looks like a bug. It should be commented that it is not a bug and it is freed this way. Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Mark Rutland <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 761ef34 commit a54665a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/trace/ftrace.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5208,8 +5208,12 @@ struct ftrace_func_map {
52085208
void *data;
52095209
};
52105210

5211+
/*
5212+
* Note, ftrace_func_mapper is freed by free_ftrace_hash(&mapper->hash).
5213+
* The hash field must be the first field.
5214+
*/
52115215
struct ftrace_func_mapper {
5212-
struct ftrace_hash hash;
5216+
struct ftrace_hash hash; /* Must be first! */
52135217
};
52145218

52155219
/**
@@ -5344,6 +5348,7 @@ void free_ftrace_func_mapper(struct ftrace_func_mapper *mapper,
53445348
}
53455349
}
53465350
}
5351+
/* This also frees the mapper itself */
53475352
free_ftrace_hash(&mapper->hash);
53485353
}
53495354

0 commit comments

Comments
 (0)