History

rv: Fix wrong type cast in enabled_monitors_next()

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.

Nam Cao committed 1 year ago

Commit de090d11 parent 03ee64b1 file · +1 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/rv/rv.c+1−1
@@ -495,7 +495,7 @@ static void *available_monitors_next(struct seq_file *m, void *p, loff_t *pos) · 494 unmodified lines
495 */495 */
496static void *enabled_monitors_next(struct seq_file *m, void *p, loff_t *pos)496static void *enabled_monitors_next(struct seq_file *m, void *p, loff_t *pos)
497{497{
498 struct rv_monitor *mon = p;498 struct rv_monitor *mon = container_of(p, struct rv_monitor, list);
499 499
500 (*pos)++;500 (*pos)++;
501 501