Skip to content

Commit 3cfb9c1

Browse files
covanamrostedt
authored andcommitted
rv: Fix wrong type cast in reactors_show() and monitor_reactor_show()
Argument 'p' of reactors_show() and monitor_reactor_show() is not a pointer to struct rv_reactor, it is actually a pointer to the list_head inside struct rv_reactor. Therefore it's wrong to cast 'p' to struct rv_reactor *. This wrong type cast has been there since the beginning. But it still worked because the list_head was the first field in struct rv_reactor_def. This is no longer true since commit 3d3c376 ("rv: Merge struct rv_reactor_def into struct rv_reactor") moved the list_head, and this wrong type cast became a functional problem. Properly use container_of() instead. Cc: Masami Hiramatsu <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Gabriele Monaco <[email protected]> Link: https://lore.kernel.org/b4febbd6844311209e4c8768b65d508b81bd8c9b.1753625621.git.namcao@linutronix.de Fixes: 3d3c376 ("rv: Merge struct rv_reactor_def into struct rv_reactor") Signed-off-by: Nam Cao <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent e82aea5 commit 3cfb9c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/trace/rv/rv_reactors.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static struct rv_reactor *get_reactor_rdef_by_name(char *name)
8686
*/
8787
static int reactors_show(struct seq_file *m, void *p)
8888
{
89-
struct rv_reactor *reactor = p;
89+
struct rv_reactor *reactor = container_of(p, struct rv_reactor, list);
9090

9191
seq_printf(m, "%s\n", reactor->name);
9292
return 0;
@@ -139,7 +139,7 @@ static const struct file_operations available_reactors_ops = {
139139
static int monitor_reactor_show(struct seq_file *m, void *p)
140140
{
141141
struct rv_monitor *mon = m->private;
142-
struct rv_reactor *reactor = p;
142+
struct rv_reactor *reactor = container_of(p, struct rv_reactor, list);
143143

144144
if (mon->reactor == reactor)
145145
seq_printf(m, "[%s]\n", reactor->name);

0 commit comments

Comments
 (0)