Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9454075pxu; Mon, 28 Dec 2020 17:08:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAL6K5Ia0luq7gznHVmsrYPYT0TyYPzbEqA6wrQJVxkCoPX9eVxzYRlARfdRY/I+tqogEQ X-Received: by 2002:a17:906:94c5:: with SMTP id d5mr42487230ejy.427.1609204100540; Mon, 28 Dec 2020 17:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609204100; cv=none; d=google.com; s=arc-20160816; b=RLojrz9XqIL7XJr9CPkPxPhzSt0yHAvjYOeYqo25eqG3lmjaEE+FdV1tOwQ/af9Wcw lypp9pWsM6bWITQrROrh/cyenWKMyMCNNWQ6zq4I9FcrcwejBpf31v/wiZRvC3cxbvxp UIA0uDXiKPmzitz3B6rC5kzfe9kyQTKC0p8LKXmQlr2zL4LsyOFEVV8Lr3kZOaeytaSJ Dw+8BVy1sI1Nkp8/8kzuTG4OyDlP7acwpcp02YZLoOMybvLEI0uHgXlNvRMpJyAtGCSL ERDY4yZYkj4ETTCfNCjUXPA/P/MZih1new/9VmMc/2Bu4/B+uBJOTD8BF6G/NmkM57/v Ysgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bFBo0MkjpsVIDqW8Mp9NsBdbkj3uUJjhIJTOvomJptc=; b=UHEemcYivva0bZnR27lW/2Cy6rNf92HKBmlWHuImtKG+NaLtCjDYuZYEfo4RhwkUVG 4JJJHRGU4Y106TtQvpLBmbc7fE4IvB8IfPUvqICIfjobs1Yt5IHxVGaQFcGfLGypOWnp gUXJxMxVws6YXkhKQp3nCU9qodnUMPzrxp+Etc7/Z9B5uSHXyWZ385/rNaLZy/4jcSna TE5oWorTFRTEo+OYpAo7qODErEeITB36xeAm2sA3fldFbMHaidQuPsU6YpLEs1UvfF4A /UiVyTX0d2pZBeqS0cfmuqDgRKm0FrE0ohT05UKjqR355phcGZfAhAmRXrg+W0NWhXGC J0kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aZMpVpvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si19483938ejt.709.2020.12.28.17.07.58; Mon, 28 Dec 2020 17:08:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aZMpVpvw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730580AbgL1QbS (ORCPT + 99 others); Mon, 28 Dec 2020 11:31:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:34164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728096AbgL1NGX (ORCPT ); Mon, 28 Dec 2020 08:06:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0EA2522573; Mon, 28 Dec 2020 13:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160742; bh=FyR/7yesFD8c3AUgFGAKvtK+gPXqYGUgHihsinTiIq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aZMpVpvwf63DwAmoy1nbAFXCsg6Umnxc70UVJ1qxMKMblqE3fgth1W8u9ZZKjzFXK 7Ffg+cDE9HJZ8CARN71CmAbBTjnsIa+H0kCiXxiQECZAk46AHsnzHYVosaFrB5WVOT 3Ecs1+C7t39+tpaZYTLCHlOpLOoBznJ/veWyQVz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheng Zengkai , Jiri Olsa , Alexander Shishkin , Li Bin , Mark Rutland , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.9 125/175] =?UTF-8?q?perf=20record:=20Fix=20memory=20leak=20when=20using=20?= =?UTF-8?q?--user-regs=3D=3F=20to=20list=20registers?= Date: Mon, 28 Dec 2020 13:49:38 +0100 Message-Id: <20201228124859.308604190@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheng Zengkai [ Upstream commit 2eb5dd418034ecea2f7031e3d33f2991a878b148 ] When using 'perf record's option '-I' or '--user-regs=' along with argument '?' to list available register names, memory of variable 'os' allocated by strdup() needs to be released before __parse_regs() returns, otherwise memory leak will occur. Fixes: bcc84ec65ad1 ("perf record: Add ability to name registers to record") Signed-off-by: Zheng Zengkai Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Li Bin Cc: Mark Rutland Cc: Namhyung Kim Link: https://lore.kernel.org/r/20200703093344.189450-1-zhengzengkai@huawei.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/parse-regs-options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/parse-regs-options.c b/tools/perf/util/parse-regs-options.c index 646ecf736aadb..be2ab1091c2bb 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -40,7 +40,7 @@ parse_regs(const struct option *opt, const char *str, int unset) } fputc('\n', stderr); /* just printing available regs */ - return -1; + goto error; } for (r = sample_reg_masks; r->name; r++) { if (!strcasecmp(s, r->name)) -- 2.27.0