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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <de57c10a-1dbf-098a-27da-6f16275e5979@web.de>
Date:   Thu, 2 Jul 2020 17:07:25 +0200
From:   Markus Elfring <Markus.Elfring@....de>
To:     tongtiangen <tongtiangen@...wei.com>,
        kernel-janitors@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...hat.com>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Mark Rutland <mark.rutland@....com>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Wei Yongjun <weiyongjun1@...wei.com>
Subject: Re: [PATCH] perf header: Fix possible memory leak when using
 do_read_string

> In the header.c file, some functions allocate memory after using
> do_read_string, but the corresponding memory is not released after
> subsequent processing errors, causing memory leaks.

I suggest to choose an imperative wording for this change description.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=cd77006e01b3198c75fb7819b3d0ff89709539bb#n151


…
> +++ b/tools/perf/util/header.c
> @@ -2307,8 +2307,10 @@  static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
>  			goto error;
>
>  		/* include a NULL character at the end */
> -		if (strbuf_add(&sb, str, strlen(str) + 1) < 0)
> +		if (strbuf_add(&sb, str, strlen(str) + 1) < 0) {
> +			free(str);
>  			goto error;
> +		}
>  		size += string_size(str);
…

I propose to add the jump target “free_str” for nicer exception handling
in this function implementation.

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ