]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rv: Fix wrong type cast in enabled_monitors_next()
authorNam Cao <namcao@linutronix.de>
Wed, 6 Aug 2025 12:09:11 +0000 (14:09 +0200)
committerGabriele Monaco <gmonaco@redhat.com>
Mon, 15 Sep 2025 06:36:35 +0000 (08:36 +0200)
Argument 'p' of enabled_monitors_next() is not a pointer to struct
rv_monitor, it is actually a pointer to the list_head inside struct
rv_monitor. Therefore it is wrong to cast 'p' to struct rv_monitor *.

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_monitor_def.
This is no longer true since commit 24cbfe18d55a ("rv: Merge struct
rv_monitor_def into struct rv_monitor") moved the list_head, and this wrong
type cast became a functional problem.

Properly use container_of() instead.

Fixes: 24cbfe18d55a ("rv: Merge struct rv_monitor_def into struct rv_monitor")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/r/20250806120911.989365-1-namcao@linutronix.de
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
kernel/trace/rv/rv.c

index 1482e91c39f4029e7f119be27c86d90c5758b45a..b341445b8fbdf1cc775132f731e37588f0fe1d15 100644 (file)
@@ -495,7 +495,7 @@ static void *available_monitors_next(struct seq_file *m, void *p, loff_t *pos)
  */
 static void *enabled_monitors_next(struct seq_file *m, void *p, loff_t *pos)
 {
-       struct rv_monitor *mon = p;
+       struct rv_monitor *mon = container_of(p, struct rv_monitor, list);
 
        (*pos)++;