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
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -3865,7 +3865,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data) · 3864 unmodified lines | |||
| 3865 | 3865 | ||
| 3866 | s = kstrdup(field_str, GFP_KERNEL); | 3866 | s = kstrdup(field_str, GFP_KERNEL); |
| 3867 | if (!s) { | 3867 | if (!s) { |
| 3868 | kfree(hist_data->attrs->var_defs.name[n_vars]); | ||
| 3869 | ret = -ENOMEM; | 3868 | ret = -ENOMEM; |
| 3870 | goto free; | 3869 | goto free; |
| 3871 | } | 3870 | } |