mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
tracing: Use __free() for expr_str() buffer
expr_str() allocates a temporary expression buffer and manually frees it on some error paths. Convert the buffer to __free(kfree) and return it with return_ptr() on success. This keeps ownership handling separate from the later ERR_PTR() conversion and string-bound change. Link: https://patch.msgid.link/20260611055945.22348-2-pengpeng@iscas.ac.cn Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
b11d9af16d
commit
988995c055
|
|
@ -1759,7 +1759,7 @@ static void expr_field_str(struct hist_field *field, char *expr)
|
|||
|
||||
static char *expr_str(struct hist_field *field, unsigned int level)
|
||||
{
|
||||
char *expr;
|
||||
char *expr __free(kfree) = NULL;
|
||||
|
||||
if (level > 1)
|
||||
return NULL;
|
||||
|
|
@ -1770,7 +1770,7 @@ static char *expr_str(struct hist_field *field, unsigned int level)
|
|||
|
||||
if (!field->operands[0]) {
|
||||
expr_field_str(field, expr);
|
||||
return expr;
|
||||
return_ptr(expr);
|
||||
}
|
||||
|
||||
if (field->operator == FIELD_OP_UNARY_MINUS) {
|
||||
|
|
@ -1778,16 +1778,15 @@ static char *expr_str(struct hist_field *field, unsigned int level)
|
|||
|
||||
strcat(expr, "-(");
|
||||
subexpr = expr_str(field->operands[0], ++level);
|
||||
if (!subexpr) {
|
||||
kfree(expr);
|
||||
if (!subexpr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcat(expr, subexpr);
|
||||
strcat(expr, ")");
|
||||
|
||||
kfree(subexpr);
|
||||
|
||||
return expr;
|
||||
return_ptr(expr);
|
||||
}
|
||||
|
||||
expr_field_str(field->operands[0], expr);
|
||||
|
|
@ -1806,13 +1805,12 @@ static char *expr_str(struct hist_field *field, unsigned int level)
|
|||
strcat(expr, "*");
|
||||
break;
|
||||
default:
|
||||
kfree(expr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
expr_field_str(field->operands[1], expr);
|
||||
|
||||
return expr;
|
||||
return_ptr(expr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user