Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9090924pxu; Mon, 28 Dec 2020 06:24:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIHrnKmSZfwchXHlxsXazHon+Lh6pPc+PF8SSn1GvKqhsJb/7QRKKpj7GWQhIFwPpfZEUX X-Received: by 2002:a50:a6c2:: with SMTP id f2mr42366915edc.7.1609165497320; Mon, 28 Dec 2020 06:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165497; cv=none; d=google.com; s=arc-20160816; b=IbXtjXwTvh0r0/LmPA+JqJHYhCrLbwyWtm9fVpmlGqrhScSVPD1zal/aRpQBD9O8Ba kaO/7VeZViR32il4jPSQFepADFzGdnxrFGdC/2Cg5WOCP2mPmXbSXEKO/moULEOOiKGM wrxGoSV0SkWBQ/EDxiZtnHk5gTM5mAt3l1I6P62Bqm/nRoyKQDaU5rzKV9nVz86WOH3F /zDRXbah7Pvq866FG6OAqbZ3ts+x6IxRc80b+W2oh6Rj84GQpODsOpADa87mf8E1U2S2 9DyMkNl8rxH3Umgy9ypExgxpCmdQaJAsatLxdQHzDDv/lqW/TqJRwZ2Z8fXZnO9ctsog X5yA== 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=ntFaWn0nI3Z5SjSZIh0ZfTyNDvn5SGW9a1FXiLbvGZk=; b=KdoxLxKsZwfXXh8y2opsq4L0RRWkefYXmzOE0IKg2jerW8FlQcfFTInKKF0fV4/tAk I0KTF4s2SQdJ3nuZtOY/ATScyEqRI3uJA+fhdZq54Y5cpfEIZ2IjzUEPW0JgiJJcXV6i zOGN6ykmMspHR+Y8ycjg0T8Y3blN3ZAPTrL8m4NrGc0QXiLcefuYOQDmqWc5Ufkujoyk R87vAp6rH8j8Bn1V7s13aJ1xQotL8ZeWCjW3PFKtEd5+MBTCsSBnJFjbtSccLtzs7anB mM0MWNW9XMhOFEhpn58WEdby605pD+L4TYWumvfY//hBciN2Hw+qSV9UFL8FIR6oe59h nZgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vwI8ZTFF; 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 me7si19039278ejb.11.2020.12.28.06.24.34; Mon, 28 Dec 2020 06:24:57 -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=vwI8ZTFF; 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 S2441656AbgL1OWE (ORCPT + 99 others); Mon, 28 Dec 2020 09:22:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:56246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441252AbgL1OV6 (ORCPT ); Mon, 28 Dec 2020 09:21:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EB4920731; Mon, 28 Dec 2020 14:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165302; bh=BZUg49SXJ9bvdj7cXdmmm46G9A4x6QGtph8VF/n4wwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vwI8ZTFFYmTj2P/Opqf2TxysuAqMU8oERZePrc9pYC9f4oRDXIFwPn8CnhCMj5ohS TshD34FEi8/iQgbZgOCKO3Yec+xrnH4ZrljcvIo+1RjrpGJcBNO7IjqqH3x0YmUt2W ZC4wAR+G6ijpT24aF3aImRiBIo7yj0ZcXWyt1h3k= 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 5.10 485/717] =?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:48:03 +0100 Message-Id: <20201228125044.198705734@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 e687497b3aac0..a4a100425b3a2 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -54,7 +54,7 @@ __parse_regs(const struct option *opt, const char *str, int unset, bool intr) #endif fputc('\n', stderr); /* just printing available regs */ - return -1; + goto error; } #ifdef HAVE_PERF_REGS_SUPPORT for (r = sample_reg_masks; r->name; r++) { -- 2.27.0