From: Mukesh Ojha <quic_mojha@quicinc.com>
To: <borrello@diag.uniroma1.it>
Cc: <c.giuffrida@vu.nl>, <h.j.bos@vu.nl>, <jkl820.git@gmail.com>,
<linux-kernel@vger.kernel.org>,
<linux-trace-kernel@vger.kernel.org>, <mhiramat@kernel.org>,
<rostedt@goodmis.org>
Subject: Re: [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
Date: Fri, 17 Feb 2023 19:12:40 +0530 [thread overview]
Message-ID: <1676641360-22701-1-git-send-email-quic_mojha@quicinc.com> (raw)
In-Reply-To: <20230128-list-entry-null-check-v1-1-8bde6a3da2ef@diag.uniroma1.it>
>All callers of trace_probe_primary_from_call() check the return
>value to be non NULL. However, the function returns
>list_first_entry(&tpe->probes, ...) which can never be NULL.
>Additionally, it does not check for the list being possibly empty,
>possibly causing a type confusion on empty lists.
>Use list_first_entry_or_null() which solves both problems.
>
>Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
>Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
>---
> kernel/trace/trace_probe.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
>index 23acfd1c3812..f6b565dced56 100644
>--- a/kernel/trace/trace_probe.h
>+++ b/kernel/trace/trace_probe.h
>@@ -307,7 +307,7 @@ trace_probe_primary_from_call(struct trace_event_call *call)
> {
> struct trace_probe_event *tpe = trace_probe_event_from_call(call);
>
>- return list_first_entry(&tpe->probes, struct trace_probe, list);
>+ return list_first_entry_or_null(&tpe->probes, struct trace_probe, list);
> }
Nice catch !!
Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
-Mukesh
>
> static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
prev parent reply other threads:[~2023-02-17 13:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-28 16:23 [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry Pietro Borrello
2023-01-30 15:19 ` Steven Rostedt
2023-02-17 1:30 ` Masami Hiramatsu
2023-02-17 13:42 ` Mukesh Ojha [this message]
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=1676641360-22701-1-git-send-email-quic_mojha@quicinc.com \
--to=quic_mojha@quicinc.com \
--cc=borrello@diag.uniroma1.it \
--cc=c.giuffrida@vu.nl \
--cc=h.j.bos@vu.nl \
--cc=jkl820.git@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).