All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: tom.zanussi@linux.intel.com
Cc: Steven Rostedt <rostedt@goodmis.org>, kernel-janitors@vger.kernel.org
Subject: [bug report] tracing: Allow whitespace to surround hist trigger filter
Date: Tue, 18 Jan 2022 12:38:09 +0300	[thread overview]
Message-ID: <20220118093809.GA13017@kili> (raw)

[ This is an older warning but renaming the function made it appear in
  the new warnings list.  I have searched my outbox and I don't think
  I forwarded this one before.  -dan ]

Hello Tom Zanussi,

The patch ec5ce0987541: "tracing: Allow whitespace to surround hist
trigger filter" from Jan 15, 2018, leads to the following Smatch
static checker warning:

	kernel/trace/trace_events_hist.c:6199 event_hist_trigger_parse()
	warn: 'p' can't be NULL.

kernel/trace/trace_events_hist.c
    6149 static int event_hist_trigger_parse(struct event_command *cmd_ops,
    6150                                     struct trace_event_file *file,
    6151                                     char *glob, char *cmd, char *param)
    6152 {
    6153         unsigned int hist_trigger_bits = TRACING_MAP_BITS_DEFAULT;
    6154         struct event_trigger_data *trigger_data;
    6155         struct hist_trigger_attrs *attrs;
    6156         struct event_trigger_ops *trigger_ops;
    6157         struct hist_trigger_data *hist_data;
    6158         struct synth_event *se;
    6159         const char *se_name;
    6160         bool remove = false;
    6161         char *trigger, *p, *start;
    6162         int ret = 0;
    6163 
    6164         lockdep_assert_held(&event_mutex);
    6165 
    6166         if (glob && strlen(glob)) {
    6167                 hist_err_clear();
    6168                 last_cmd_set(file, param);
    6169         }
    6170 
    6171         if (!param)
    6172                 return -EINVAL;
    6173 
    6174         if (glob[0] == '!')
    6175                 remove = true;
    6176 
    6177         /*
    6178          * separate the trigger from the filter (k:v [if filter])
    6179          * allowing for whitespace in the trigger
    6180          */
    6181         p = trigger = param;
    6182         do {
    6183                 p = strstr(p, "if");
    6184                 if (!p)
    6185                         break;
    6186                 if (p == param)
    6187                         return -EINVAL;
    6188                 if (*(p - 1) != ' ' && *(p - 1) != '\t') {
    6189                         p++;
    6190                         continue;
                                 ^^^^^^^^^

These are the continue paths

    6191                 }
    6192                 if (p >= param + strlen(param) - (sizeof("if") - 1) - 1)
    6193                         return -EINVAL;
    6194                 if (*(p + sizeof("if") - 1) != ' ' && *(p + sizeof("if") - 1) != '\t') {
    6195                         p++;
    6196                         continue;
                                 ^^^^^^^^^

    6197                 }
    6198                 break;
--> 6199         } while (p);

Should this be } while(*p);?

    6200 
    6201         if (!p)
    6202                 param = NULL;
    6203         else {
    6204                 *(p - 1) = '\0';
    6205                 param = strstrip(p);
    6206                 trigger = strstrip(trigger);
    6207         }
    6208 

regards,
dan carpenter

             reply	other threads:[~2022-01-18  9:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  9:38 Dan Carpenter [this message]
2022-01-18 16:22 ` [bug report] tracing: Allow whitespace to surround hist trigger filter Zanussi, Tom

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=20220118093809.GA13017@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tom.zanussi@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.