Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp673901pxv; Thu, 15 Jul 2021 13:08:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJya/DqLhDOmju1FTIi58cRXiFcTi9GvbLfeKH7QPaSt2mtoglbr4dz+uJ1ys+hgfAkbnvZx X-Received: by 2002:a5d:9b14:: with SMTP id y20mr4433403ion.8.1626379715422; Thu, 15 Jul 2021 13:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626379715; cv=none; d=google.com; s=arc-20160816; b=BYbMrVa1G5UQ5bBBZqW+45Qo64RPNDlQr1kPOm2dOMxP688ghmfexm7zZnovBZRAQH MuCrYjEtPZIV+UwXwDPuFyzVTlrQRIenXPCtLxAsaeUNcGxwE9KjcaYRUpfRc/HZFPvK VK4XKn+/+XQFBcPf5o1QI63qnbzEFkleJqIlNQ7yAxBBdqXG3jXCqgckCFtsSduq1JaY iaoUFXK4Yc2l+Rz7tfhH4s694fAE3FqPdIAc3UqiQCJNgtOlkLBCefRDkRAZUth8Y5UG dYGHPim7ky+r+xonITEIPgaRAzOLphWD6/ls0FqzsQukpmfLbofYqjIyx1pNvCYB9fKX RoiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RodaQjhM8dk8KTjjfbHkA7UGSHJS6XQLJpsLsWMHpXU=; b=kpXlp6+40er0eUjA/ky74mW/AWJ5p6SuHohBhp79mz/Zq88tltuOD7cxwhLXwpS9F1 fCPT1y8CjFZz2tCw9J6+2DDFNqOAjNZaCsLxuhnUDvm6TeLyifqLmvqvBDASe/0bKh/x 3JgZ0KfO5xJ5CCpmmEs+gJW8YNAKP561JAQfEa6a2Bi4JMfSo0QiMtlkOPct6QLYD9ib SpXFeRUj5XTn5bzCR18R7KlcYWOb4urlZzx8itWzBkTkw309wOXC0u+URcAF7UGFnWYh dUMAa93EFe0cA+Hkme3xONq8QnMWlPuhQHa5f23430bYwEnlBf7/bC7ehJCzQ7KyhiEB etuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YR17l5wl; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u2si7834369ilq.111.2021.07.15.13.08.22; Thu, 15 Jul 2021 13:08:35 -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=@kernel.org header.s=k20201202 header.b=YR17l5wl; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238211AbhGOUKV (ORCPT + 99 others); Thu, 15 Jul 2021 16:10:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237428AbhGOUKS (ORCPT ); Thu, 15 Jul 2021 16:10:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06DA5613BB; Thu, 15 Jul 2021 20:07:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626379645; bh=K5MRPmLvT25SpKV4UrNDisb7Z3VHaPFGmFuDsU3OKFM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YR17l5wlk+WMsVLc2WQRQaDSBNlogcxcQYf75ek3+kz+rFb1VCipkEzdjzTDACgKs /AUYPWGlLOfskIQdbaR007zKgcJZ8O++0AR6fQfiUNm+0aRZ0Bzwb1HOM0GWJghWeo aSjstWSbg3PAlxACo+PX6axS1wq8q5Z3h0O966QbnE92ruS/KvWmo5J8jfjTFEd9CC 49SgfM01gfyZiBrHwnKO189eMX++mQsoPx4FOVsjVOAfWgBIvJH4vGvtz+iCBHiS2t +oYPRru4CHdksklZAz4zftH6UmpXDyqRzUU0ijOs7WiFTzLEp6/ejqZoKm2fT1cLO9 K40jnWjNPPHdw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id BE860403F2; Thu, 15 Jul 2021 17:07:22 -0300 (-03) Date: Thu, 15 Jul 2021 17:07:22 -0300 From: Arnaldo Carvalho de Melo To: Riccardo Mancini Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH 06/20] perf dso: fix memory leak in dso__new_map Message-ID: References: <60bfe0cd06e89e2ca33646eb8468d7f5de2ee597.1626343282.git.rickyman7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60bfe0cd06e89e2ca33646eb8468d7f5de2ee597.1626343282.git.rickyman7@gmail.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Jul 15, 2021 at 06:07:11PM +0200, Riccardo Mancini escreveu: > ASan reports a memory leak when running the 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. Fixes: d3a7c489c7fd2463 ("perf tools: Reference count struct dso") Thanks, applied. - Arnaldo > Signed-off-by: Riccardo Mancini > --- > 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 d786cf6b0cfa65f2..ee15db2be2f43403 100644 > --- a/tools/perf/util/dso.c > +++ b/tools/perf/util/dso.c > @@ -1154,8 +1154,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.31.1 > -- - Arnaldo