History

tracing: fix double free

clang static analyzer reports this problem trace_events_hist.c:3824:3: warning: Attempt to free released memory kfree(hist_data->attrs->var_defs.name[i]); In parse_var_defs() if there is a problem allocating var_defs.expr, the earlier var_defs.name is freed. This free is duplicated by free_var_defs() which frees the rest of the list. Because free_var_defs() has to run anyway, remove the second free fom parse_var_defs(). Link: https://lkml.kernel.org/r/20200907135845.15804-1-trix@redhat.com

Tom Rix committed 6 years ago

Commit 46bbe5c1 parent 54fa9ba1 file · +0 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_events_hist.c+0−1
@@ -3865,7 +3865,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data) · 3864 unmodified lines
38653865
38663866 s = kstrdup(field_str, GFP_KERNEL);
38673867 if (!s) {
3868− kfree(hist_data->attrs->var_defs.name[n_vars]);
38693868 ret = -ENOMEM;
38703869 goto free;
38713870 }