]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tracing/histogram: Fix check for missing operands in an expression
authorKalesh Singh <kaleshsingh@google.com>
Fri, 12 Nov 2021 19:13:24 +0000 (11:13 -0800)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 12 Nov 2021 20:55:59 +0000 (15:55 -0500)
If a binary operation is detected while parsing an expression string,
the operand strings are deduced by splitting the experssion string at
the position of the detected binary operator. Both operand strings are
sub-strings (can be empty string) of the expression string but will
never be NULL.

Currently a NULL check is used for missing operands, fix this by
checking for empty strings instead.

Link: https://lkml.kernel.org/r/20211112191324.1302505-1-kaleshsingh@google.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Fixes: dfdca7209867 ("tracing: Fix operator precedence for hist triggers expression")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c

index 6a9fa34e2785ccf3e7d9e745dddc63e67955e655..1475d7347fe0c10aac810a9de0c9a0d387361524 100644 (file)
@@ -2581,7 +2581,8 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
        operand1_str = str;
        str = sep+1;
 
-       if (!operand1_str || !str)
+       /* Binary operator requires both operands */
+       if (*operand1_str == '\0' || *str == '\0')
                goto free;
 
        operand_flags = 0;