public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Costa Shulyupin <costa.shul@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	Daniel Bristot de Oliveira <bristot@kernel.org>,
	John Kacur <jkacur@redhat.com>,
	"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
	Eder Zulian <ezulian@redhat.com>,
	Tomas Glozar <tglozar@redhat.com>,
	Gabriele Monaco <gmonaco@redhat.com>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] rtla: Fix implicit NULL dereference
Date: Fri, 10 Jan 2025 08:38:35 +0300	[thread overview]
Message-ID: <16990bcc-c328-457b-a789-0f318d8eaf3f@stanley.mountain> (raw)
In-Reply-To: <20250109211358.2619367-1-costa.shul@redhat.com>

The subject is bad because it says "Fix" when this is a clean up
and it says "NULL dereference" when there isn't any NULL dereference.

On Thu, Jan 09, 2025 at 11:13:26PM +0200, Costa Shulyupin wrote:
> The `record` variable is NULL when tracing is not requested:
> 
> struct osnoise_tool *record = NULL;
> 
> if (params->trace_output) {
>         record = osnoise_init_trace_tool("osnoise");
> ....
> 
> Value of `&record->trace` in this case is NULL just because
> the `trace` member is the first member `struct osnoise_tool` with offset 0.
> `&record->trace` just returns the offset.
> 
> Explicit dereference `record->trace' would cause segmentation fault.
> 
> Add explicit check for zero `record`.
> 

This commit message is very confusing.  I would normally not send a
patch like this, but if I did send it the commit message would say
something like:

  The "record" pointer can be NULL in this code.  When we're calling
  trace_is_off(&tool->trace, &record->trace) and "record" is NULL then
  it kind of looks like a NULL dereference.  It turns out that it's
  fine when you look at it more closely, but at first glance it looks
  sketchy.  Add an explicit NULL check to make the code more clear.

Tracing code is generally fast path code so maybe we don't want to add
a NULL check?  If we were really bothered by the existing code then a
better fix would be to add an inline function to do it.

regards,
dan carpenter


  reply	other threads:[~2025-01-10  5:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 21:13 [PATCH v1] rtla: Fix implicit NULL dereference Costa Shulyupin
2025-01-10  5:38 ` Dan Carpenter [this message]
2025-01-10 13:05   ` Steven Rostedt

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=16990bcc-c328-457b-a789-0f318d8eaf3f@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=bristot@kernel.org \
    --cc=costa.shul@redhat.com \
    --cc=ezulian@redhat.com \
    --cc=gmonaco@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    /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