Skip to contentSkip to conversation

tracing/histogram: Fix check for missing operands in an expression

PATCH New Kalesh Singh 1 participant 1 message Nov 12, 2021 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/histogram: Fix check for missing operands in an expression

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.

Fixes 9710b2f341a0 ("tracing: Fix operator precedence for hist triggers expression")
---
 kernel/trace/trace_events_hist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +2 -1
index 0abc9a413b4d..328b1f83a3c8 100644
@@ -2580,7 +2580,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;

base-commit: 5833291ab6de9c3e2374336b51c814e515e8f3a5

Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog