From: Gabriele Monaco <gmonaco@redhat.com>
To: Nam Cao <namcao@linutronix.de>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rv: Fix wrong type cast in enabled_monitors_next()
Date: Wed, 06 Aug 2025 14:45:22 +0200 [thread overview]
Message-ID: <8f379f2072ee12afda37455aa0ad4e37d53c4f2d.camel@redhat.com> (raw)
In-Reply-To: <20250806120911.989365-1-namcao@linutronix.de>
On Wed, 2025-08-06 at 14:09 +0200, Nam Cao wrote:
> 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.
Good catch, thanks!
Reviewed-by: Gabriele Monaco <gmonaco@redhat.com>
>
> Fixes: 24cbfe18d55a ("rv: Merge struct rv_monitor_def into struct
> rv_monitor")
> Signed-off-by: Nam Cao <namcao@linutronix.de>
> ---
> kernel/trace/rv/rv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/rv/rv.c b/kernel/trace/rv/rv.c
> index bd7d56dbf6c2..6ce3495164d8 100644
> --- a/kernel/trace/rv/rv.c
> +++ b/kernel/trace/rv/rv.c
> @@ -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)++;
>
next prev parent reply other threads:[~2025-08-06 12:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-06 12:09 [PATCH] rv: Fix wrong type cast in enabled_monitors_next() Nam Cao
2025-08-06 12:45 ` Gabriele Monaco [this message]
2025-09-23 0:20 ` Nathan Chancellor
2025-09-23 5:28 ` Nam Cao
2025-09-23 8:30 ` Gabriele Monaco
2025-09-23 8:44 ` Nam Cao
2025-09-23 8:53 ` Gabriele Monaco
2025-09-23 9:43 ` Gabriele Monaco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8f379f2072ee12afda37455aa0ad4e37d53c4f2d.camel@redhat.com \
--to=gmonaco@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=namcao@linutronix.de \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox