lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200305151352.GD7895@kernel.org>
Date:   Thu, 5 Mar 2020 12:13:52 -0300
From:   Arnaldo Carvalho de Melo <arnaldo.melo@...il.com>
To:     John Garry <john.garry@...wei.com>
Cc:     peterz@...radead.org, mingo@...hat.com, mark.rutland@....com,
        alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
        namhyung@...nel.org, will@...nel.org, ak@...ux.intel.com,
        linuxarm@...wei.com, linux-kernel@...r.kernel.org,
        james.clark@....com, qiangqing.zhang@....com
Subject: Re: [PATCH 1/6] perf jevents: Fix leak of mapfile memory

Em Thu, Mar 05, 2020 at 07:08:01PM +0800, John Garry escreveu:
> The memory for global pointer is never freed during normal program
> execution, so let's do that in the main function exit as a good programming
> practice.
> 
> A stray blank line is also removed.

Thanks, applied to perf/urgent.

- Arnaldo
 
> Reported-by: Jiri Olsa <jolsa@...hat.com>
> Signed-off-by: John Garry <john.garry@...wei.com>
> ---
>  tools/perf/pmu-events/jevents.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
> index 079c77b6a2fd..27b4da80f751 100644
> --- a/tools/perf/pmu-events/jevents.c
> +++ b/tools/perf/pmu-events/jevents.c
> @@ -1082,10 +1082,9 @@ static int process_one_file(const char *fpath, const struct stat *sb,
>   */
>  int main(int argc, char *argv[])
>  {
> -	int rc;
> +	int rc, ret = 0;
>  	int maxfds;
>  	char ldirname[PATH_MAX];
> -
>  	const char *arch;
>  	const char *output_file;
>  	const char *start_dirname;
> @@ -1156,7 +1155,8 @@ int main(int argc, char *argv[])
>  		/* Make build fail */
>  		fclose(eventsfp);
>  		free_arch_std_events();
> -		return 1;
> +		ret = 1;
> +		goto out_free_mapfile;
>  	} else if (rc) {
>  		goto empty_map;
>  	}
> @@ -1174,14 +1174,17 @@ int main(int argc, char *argv[])
>  		/* Make build fail */
>  		fclose(eventsfp);
>  		free_arch_std_events();
> -		return 1;
> +		ret = 1;
>  	}
>  
> -	return 0;
> +
> +	goto out_free_mapfile;
>  
>  empty_map:
>  	fclose(eventsfp);
>  	create_empty_mapping(output_file);
>  	free_arch_std_events();
> -	return 0;
> +out_free_mapfile:
> +	free(mapfile);
> +	return ret;
>  }
> -- 
> 2.17.1
> 

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ