linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot2 for Yunfeng Ye" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Yunfeng Ye <yeyunfeng@huawei.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Feilong Lin <linfeilong@huawei.com>,
	Hu Shiyuan <hushiyuan@huawei.com>, Jiri Olsa <jolsa@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ingo Molnar <mingo@kernel.org>, Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org
Subject: [tip: perf/urgent] perf kmem: Fix memory leak in compact_gfp_flags()
Date: Mon, 21 Oct 2019 06:26:40 -0000	[thread overview]
Message-ID: <157163920042.29376.8707217157617619218.tip-bot2@tip-bot2> (raw)
In-Reply-To: <f9e9f458-96f3-4a97-a1d5-9feec2420e07@huawei.com>

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     1abecfcaa7bba21c9985e0136fa49836164dd8fd
Gitweb:        https://git.kernel.org/tip/1abecfcaa7bba21c9985e0136fa49836164dd8fd
Author:        Yunfeng Ye <yeyunfeng@huawei.com>
AuthorDate:    Wed, 16 Oct 2019 16:38:45 +08:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Wed, 16 Oct 2019 10:08:32 -03:00

perf kmem: Fix memory leak in compact_gfp_flags()

The memory @orig_flags is allocated by strdup(), it is freed on the
normal path, but leak to free on the error path.

Fix this by adding free(orig_flags) on the error path.

Fixes: 0e11115644b3 ("perf kmem: Print gfp flags in human readable string")
Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Feilong Lin <linfeilong@huawei.com>
Cc: Hu Shiyuan <hushiyuan@huawei.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/f9e9f458-96f3-4a97-a1d5-9feec2420e07@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-kmem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 1e61e35..9661671 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
 			new = realloc(new_flags, len + strlen(cpt) + 2);
 			if (new == NULL) {
 				free(new_flags);
+				free(orig_flags);
 				return NULL;
 			}
 

      parent reply	other threads:[~2019-10-21  6:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16  8:38 [PATCH] perf kmem: Fix memory leak in compact_gfp_flags() Yunfeng Ye
2019-10-16 13:04 ` Arnaldo Carvalho de Melo
2019-10-16 13:09   ` Arnaldo Carvalho de Melo
2019-10-16 13:19     ` Yunfeng Ye
2019-10-16 14:08       ` Arnaldo Carvalho de Melo
2019-10-16 14:17         ` Yunfeng Ye
2019-10-21  6:26 ` tip-bot2 for Yunfeng Ye [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=157163920042.29376.8707217157617619218.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=hushiyuan@huawei.com \
    --cc=jolsa@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yeyunfeng@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).