Re: [PATCH] perf tools: Fix potential memory leak in perf events parser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Fix potential memory leak in function parse_events_term__sym_hw()
> and parse_events_term__clone().

Would you like to add the tag “Fixes” to the commit message?


…
> +++ b/tools/perf/util/parse-events.c
…
> @@ -2957,9 +2958,20 @@  int parse_events_term__sym_hw(struct parse_events_term **term,
>  	sym = &event_symbols_hw[idx];
>
>  	str = strdup(sym->symbol);
> -	if (!str)
> +	if (!str) {
> +		if (!config)
> +			free(temp.config);
>  		return -ENOMEM;
> -	return new_term(term, &temp, str, 0);
> +	}
> +
> +	ret = new_term(term, &temp, str, 0);
> +	if (ret < 0) {
> +		free(str);
> +		if (!config)
> +			free(temp.config);
> +	}
> +
> +	return ret;
>  }
…

How do you think about to add jump targets for a bit of
common exception handling code in these function implementations?

Regards,
Markus




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux