Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp670798pxv; Thu, 15 Jul 2021 13:03:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGcCVteQZIybngctjzb6LiSca4To1MJr0KywVL3CKcbNlZZuknwyXvKVUQTn6ypYKqZcxs X-Received: by 2002:a17:906:a08d:: with SMTP id q13mr7235628ejy.465.1626379420138; Thu, 15 Jul 2021 13:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626379420; cv=none; d=google.com; s=arc-20160816; b=uKMvI7t6ZxoBVp5yhTBj1VkQvFCW01szFpa7IxCrcOXLiSqwtim0ioM4UaGBFi1mG1 PvCZb3tbxIvHOlxK6n30rnhh7wfk+i+kHk17LtlgD3ykRAxvRsAR3pVUayibRTBT2Bz7 SbY4qae1U/NZMneJJda7+tN1oQFyP1aajunVX7EqhVis96g6XmquqeVKqLCZbW/TU5XW g+9JhWjdsfqd26aR90egmT7yQZaBBgE3wzNM6OD9IaM0vlnaRlzR+doAyjPsv7/5sQFh dF74KJ0gUYHOtsKHwg4BoeNaMDE1cJpmgicZ8zcc1NsbKkTh4I5Zab6vqE8LToQpw65M YoFw== 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=zuaNCV7KFaLmFmLK1flkCQ6fzwvmyCH7hLhDbLMHkeE=; b=TEsj78j9itJ5E5/Rf+ri3qQHjxim4lAaxykjht5ce74TB38+ZErJdOMkIp7cz2b+bR +LSRmgN7IyRi2NbvXL1/ttdpkpfap3FoE9o9oU4EUmwRTmoI/cKCW8XNJkgBcbAjxbsH VS3eGRAUuvRpPfcscn6XaZ+98+jsd6hCySSflxL87BMDN9+W4ILG55iF9K5oyJMfHU3i /HeVDepQfSDuxAE9aRnqFwrAmSXdGeQ27WMY/mTq/bmoEHFVAOkpzR4S9prQIaN0bLlL 7B7IRZS76YL9QzHhqaXFSKyHtuxclJXK6Q9imOFXfbErS9nUdnayKQeJw2IbSHoRFAJl HY6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F54UFW1v; 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 i11si10292663edb.471.2021.07.15.13.03.17; Thu, 15 Jul 2021 13:03:40 -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=F54UFW1v; 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 S245058AbhGOUFF (ORCPT + 99 others); Thu, 15 Jul 2021 16:05:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346517AbhGOUEy (ORCPT ); Thu, 15 Jul 2021 16:04:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3D466128C; Thu, 15 Jul 2021 20:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626379320; bh=IummxTc4JRlXQtiz0o5C7rVL+MKKmoxVNrkyDkv/s/k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F54UFW1vnLmr+UE5jzbfibNxLGg17oUC428MMDgos6h2er6f3oOwD8x7la5zNI7NF TywcjNLfBO2RBVeu6DO1Xk7bQzPnHiQKBVCf14S5AbsdJwWeCreAmtSIC3g8mKcz9J 0G/m420uhr0ugvUxISi8lAMu/C+IkPrAJq86xutNLgcdWDRdq6kUsNQKZcxVRPEBsv wVvfqkf79iz2mu4zuti7u/Ksz8jjQGZR8t8zrbgJ7AbKPyO3lRQBx7cdA7WrYRg6Z1 aeGSZ1Oh2cyEWBRV3nxZbXAQWyeJPj0Eava3QAAMn//rGgXtVId50p4hq2pWR8fbol PiuiTwAX+qZzQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 6AC05403F2; Thu, 15 Jul 2021 17:01:57 -0300 (-03) Date: Thu, 15 Jul 2021 17:01:57 -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. Thanks, applied. This needs some extra thinking for some unrelated issue, namely that this dso isn't linked in the machine dso list, I think this is only used by 'perf probe' :-\ I guess this won't be a problem since using the machine dso list is important just for other tools, like when traversing to get the build-ids, etc. - 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