Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3677577pxv; Mon, 26 Jul 2021 09:13:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymjvFjPQEu2jxP3d/Q9xVRSLH/o5XOJo65p2sbLt45OChHcbKlA1kDZVjTqpUaWLq+DKay X-Received: by 2002:aa7:cd73:: with SMTP id ca19mr1331227edb.113.1627315982980; Mon, 26 Jul 2021 09:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315982; cv=none; d=google.com; s=arc-20160816; b=hOrzbuHu8IJvj38ShYNiZ4xuS3NG9A3g2NbEzBOvMAJo48qwC/cZruWy8bhvFKeBg2 3T/bP4ZtlSanyaCUITM3nATwmMGvja9pFtXaE4SOEhvVzizTaBIBNpdXz2+FYSqp3Dx7 RM99wUqo84ydTSrKJSHkjvYc5ZRgpSjeYwUWigGol289YG3NFB7U5W2lsjq2fJK6ASz0 w0YCqigiMfvJb6DZNIHxuq5NNlG52YZBd3F9XXqnFa+SfDgtAkkiUYOfVJcIU7TRiZYo wmgdU72c8VIEZOp8kDw9HmX0/OqkBIq5bU8fpryi83FO/0L3mcx0ZcGrVtUdCt0r8m99 F2Nw== 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=kSDktuyCLHBGvTVK9djQnHfCBIIGyx9O+RSHd4rP7pQ=; b=Zrow8M1LmgU15AAB4vwmHEkqIFdZpIzBPt4y8sJ7PUMDPc8/bVjuGHbMLtOgfl4ThF ClMihE6oNSQzAwDJwQq4D7CPnjq8Ila6lAVmWVXVku5ERjy07JILbFB2pmpz2vcyorkI S4cB0miL+lZqVeuxU2nDa/g7QR2OMn0jc0PB0Ui5ngWGdBiaQGrz0hU9NZDA29ar+rqE m0YtFjGQf0WyapjECmeKALV3Y3EPa86p2HOJ+89m6ttk50ZUE8MX5luMrV5i5pI0Je6v jscZg+sEFz/RIcM1am1x/EdJVgZ4sU6BUQQlYMwTOsfbdZXNiL9/F7C2P45P+rW0RSSc VtrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="heB3/Ccx"; 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 c4si350337edd.252.2021.07.26.09.12.39; Mon, 26 Jul 2021 09:13:02 -0700 (PDT) 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="heB3/Ccx"; 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 S237330AbhGZP3O (ORCPT + 99 others); Mon, 26 Jul 2021 11:29:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:56584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236421AbhGZPQq (ORCPT ); Mon, 26 Jul 2021 11:16:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDFDA6056C; Mon, 26 Jul 2021 15:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315033; bh=eRUNZYO70NbrzZ0scGXxW1b2KNydt1l9KIMLaLws9Rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=heB3/Ccx3xnOhz/HSr5RFHgy2F1rXibv5I0Zg7CJQ/HGJRF84dCIg85p7ApmJU2I/ O1NF8LmZYOYdO+1v1VWfVdOaUAIBSpdHKZ/+wtHJku/sqt100+xTQhiZZY20r76uo+ UbZH/huQDx5n82tnC/H/Ug3GiSfKyx2HLzTe7yME= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 025/108] perf dso: Fix memory leak in dso__new_map() Date: Mon, 26 Jul 2021 17:38:26 +0200 Message-Id: <20210726153832.511817937@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@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: Riccardo Mancini [ Upstream commit 581e295a0f6b5c2931d280259fbbfff56959faa9 ] ASan reports a memory leak when running: # perf test "65: maps__merge_in". The causes of the leaks are two, this patch addresses only the first one, which is related to dso__new_map(). The bug is that dso__new_map() creates a new dso but never decreases the refcount it gets from creating it. This patch adds the missing dso__put(). Signed-off-by: Riccardo Mancini Fixes: d3a7c489c7fd2463 ("perf tools: Reference count struct dso") Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/60bfe0cd06e89e2ca33646eb8468d7f5de2ee597.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dso.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index ab2e130dc07a..7f07a5dc555f 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -1086,8 +1086,10 @@ struct map *dso__new_map(const char *name) struct map *map = NULL; struct dso *dso = dso__new(name); - if (dso) + if (dso) { map = map__new2(0, dso); + dso__put(dso); + } return map; } -- 2.30.2