[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJFMrCH_sq9d6R_rN3MA2H7gFYUgMB+XqMfwtg_UpyLGRjPV9w@mail.gmail.com>
Date: Sat, 12 Sep 2015 01:21:09 +0530
From: Arjun Sreedharan <arjun024@...il.com>
To: Thomas Renninger <trenn@...e.com>
Cc: linux-pm@...r.kernel.org,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cpupower: fix potential memory leak
Ping !
On 22 August 2015 at 17:31, Arjun Sreedharan <arjun024@...il.com> wrote:
> Signed-off-by: Arjun Sreedharan <arjun024@...il.com>
> ---
> tools/power/cpupower/bench/parse.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c
> index f503fb5..058a351 100644
> --- a/tools/power/cpupower/bench/parse.c
> +++ b/tools/power/cpupower/bench/parse.c
> @@ -65,7 +65,7 @@ FILE *prepare_output(const char *dirname)
> {
> FILE *output = NULL;
> int len;
> - char *filename;
> + char *filename, *filename_tmp;
> struct utsname sysdata;
> DIR *dir;
>
> @@ -80,17 +80,19 @@ FILE *prepare_output(const char *dirname)
> }
>
> len = strlen(dirname) + 30;
> - filename = malloc(sizeof(char) * len);
> + filename = malloc(sizeof(*filename) * len);
>
> if (uname(&sysdata) == 0) {
> len += strlen(sysdata.nodename) + strlen(sysdata.release);
> - filename = realloc(filename, sizeof(char) * len);
> + filename_tmp = realloc(filename, sizeof(*filename) * len);
>
> - if (filename == NULL) {
> + if (filename_tmp == NULL) {
> + free(filename);
> perror("realloc");
> return NULL;
> }
>
> + filename = filename_tmp;
> snprintf(filename, len - 1, "%s/benchmark_%s_%s_%li.log",
> dirname, sysdata.nodename, sysdata.release, time(NULL));
> } else {
> --
> 2.4.5
>
--
Arjun Sreedharan
arjunsreedharan.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists