linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Pietro Borrello <borrello@diag.uniroma1.it>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Cristiano Giuffrida <c.giuffrida@vu.nl>,
	"Bos, H.J." <h.j.bos@vu.nl>, Jakob Koschel <jkl820.git@gmail.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
Date: Fri, 17 Feb 2023 10:30:19 +0900	[thread overview]
Message-ID: <20230217103019.c182a1f6aa0f55f6a8ab5896@kernel.org> (raw)
In-Reply-To: <20230128-list-entry-null-check-v1-1-8bde6a3da2ef@diag.uniroma1.it>

On Sat, 28 Jan 2023 16:23:41 +0000
Pietro Borrello <borrello@diag.uniroma1.it> wrote:

> 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>

Looks good to me.

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

And

Fixes: 60d53e2c3b75 ("tracing/probe: Split trace_event related data from trace_probe")
Cc: stable@vger.kernel.org

Thank you!

> ---
>  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);
>  }
>  
>  static inline struct list_head *trace_probe_probe_list(struct trace_probe *tp)
> 
> ---
> base-commit: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
> change-id: 20230128-list-entry-null-check-37778efda18c
> 
> Best regards,
> -- 
> Pietro Borrello <borrello@diag.uniroma1.it>


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  parent reply	other threads:[~2023-02-17  1:30 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 [this message]
2023-02-17 13:42 ` Mukesh Ojha

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=20230217103019.c182a1f6aa0f55f6a8ab5896@kernel.org \
    --to=mhiramat@kernel.org \
    --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=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).