Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9046425pxu; Mon, 28 Dec 2020 05:19:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlLFzfQWnWVd86QVjbKfulT9eDQv3YVgSB1kwif5flJ0eW/IwTvdAO+V4oVr643fNk55U3 X-Received: by 2002:a17:906:8058:: with SMTP id x24mr39940776ejw.262.1609161586868; Mon, 28 Dec 2020 05:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161586; cv=none; d=google.com; s=arc-20160816; b=ghBu4Y/PsW4U54EwAjxEU/B7WnUC8D8xMI0QPtOcNmx3IsAn11CBnS+tdEp34ZvPin GeloGmVXIoks5WwixulfeZyyCPdsJ4H/lxFQae6812qXBz25dZ1GJAOvjx0O1MFYmNLA KMl+FPlfo/xmswTgT5ra+Ir8XDFgwktPevtbBeaeGILDzmxeZJwvPwHN6ByCx68lo+1i kJ4ZXCnoK98PJpBsnu/VSA31lEdOOR1dFWkKNAmG4TNlMeGgXT6os1lZJSiRQpIgTu51 jvLbfWisCz/FFsIBxzG4ZVX69fHhbzR0CePLJb/ouB+YkI4ypvdfkGSWhnnk655VuZC4 r5/g== 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=CO6dIpIhvRsNq2dmy2iQu+eWDa/557ys4wUTm6djpW4=; b=JFX0wgEXt9t2lBIr5g6y61LnX/tEbDcTPGP0IhG295Q6ELrnuybuA6ZPI2wouiQKdp vTcq4Q71PfvSynlVwrIRC4p2x+XdYQsAoI6vckHaTyL+tf7r0jXu7X7QDjUtyis537Qs +tPUTaC22WAtRT+RGh0ffsoND+6PennoSGhbMN4sDsM6fVBy16WGpQXELFXjx591SQ13 6uqlhSn7IMO7nOiuLiXFgyVXAmIGn340F48j2/DUB43l4qzsbB3SmxZji4R/JyFs6J01 6HtXHESSMKdWNN/EP6p2T74fTm6XpVjZ5jG6M3/yrIR4bDvoDwZw/I3PhiFOcgsNomhp LmTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d+uLk2h1; 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 t21si18342451ejf.648.2020.12.28.05.19.23; Mon, 28 Dec 2020 05:19:46 -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=d+uLk2h1; 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 S1731590AbgL1NRl (ORCPT + 99 others); Mon, 28 Dec 2020 08:17:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:45828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731548AbgL1NRZ (ORCPT ); Mon, 28 Dec 2020 08:17:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2F93C22AAA; Mon, 28 Dec 2020 13:16:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161404; bh=aFf5JEWVvxQo8R81FyuTXrBlrMNqF3NmYTsE9QYvN8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d+uLk2h1fEHUHcrteUIsz3ORPjljCwg8JpmnlOlxzkhGEj2TmnN2FJg+2+B68O5fS D+dmiFAsYzcwS1iU9dQoa+SK6wnCgxiZblGFstnoT77rUiuz7WZJ7/lWEFGqr8X2KC Z/XrO8EtwzG1cLyVsm+BzSC1rLL6/+suT8eTahx0= 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.14 173/242] =?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: <20201228124913.216991023@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 e6599e290f467..e5ad120e7f69a 100644 --- a/tools/perf/util/parse-regs-options.c +++ b/tools/perf/util/parse-regs-options.c @@ -41,7 +41,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