Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp601055pxv; Thu, 15 Jul 2021 11:13:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6cZdSLN4AKE5+OBBlu/XGa5Bq7W/bc8HHQjtTg/lnu6DVMkigTf7W6jTqMmRzToEisIu8 X-Received: by 2002:a05:6402:1692:: with SMTP id a18mr8970752edv.344.1626372831163; Thu, 15 Jul 2021 11:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626372831; cv=none; d=google.com; s=arc-20160816; b=M6JOJkh3vTqYVxqMbUq2XZNEva6twa14p5TrAOa3Io6SBHmtwUXwBiGSaNdYNis8rQ ZQ4CCCbdr8tVCHgFG8XNpDojQj8F7aUaa35BjcLJluI04P/PE9LIJKcsjQcoudk/Z2qs YhlgP/9iAN7byJyokGyLuqtL7/4xKp4lCaRhv1HPnU+4ErgcvZm0PRlPraEfag9ac1Nl W/ddLwDfL89OtkdynfSFC6NF5dyDXzztU5qdKHhL4VwJmqtLtTghFzuFF0D6ayQMtOPd MyXT/YLw8gHgjqWH2VPy0M/ywTTjMY2f4Ab5if1EZ1MhobBvmKFWYf5oaZn5B+5F+RiM O8NQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zODVNKHonSU3qYAwCTgn8Fil5BPscvRVeJSPN9g2BUw=; b=wr39JrovKxE3uU7L2gntiBV3rece9xKkBq4wm0qnPoMp30d/MMi6mLKYAw/E5gANxL IcMBtZlN1EOL7t+dX/AQUckQhjsUd7MLAeSqA5IlyY4qPNsLa9R3jeStLsQD+UnpJQeK tj7rQY7fXoZawzF2Xbtwpsx2kqSazMdC52pndisiZUqKQHc1awU0Bv6obkNaH0/1Yixk /Yod3lwBf1I+jDgybQKINl7peSDkBOvci/3E4Mmt1xDQX+jaLlaIchzDuTqarYKOm77B HGq5TdcUSMtWhbUNZ2+6Y7unQ1PWT+jb4SQx+ScQwP8+0WkyfsUPPGa8q24r0WeciKE5 o18A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IZ1LtRA5; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si8908555ejj.198.2021.07.15.11.13.25; Thu, 15 Jul 2021 11:13:51 -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=@gmail.com header.s=20161025 header.b=IZ1LtRA5; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232503AbhGOQKf (ORCPT + 99 others); Thu, 15 Jul 2021 12:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbhGOQK3 (ORCPT ); Thu, 15 Jul 2021 12:10:29 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEDC8C061760; Thu, 15 Jul 2021 09:07:35 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id g12so4052101wme.2; Thu, 15 Jul 2021 09:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zODVNKHonSU3qYAwCTgn8Fil5BPscvRVeJSPN9g2BUw=; b=IZ1LtRA5qcAHvtJqVx7FrmUCOZhSd9C1k2MHghA/4JwXydzKrSAzg6nqj9bSZovTAd qZ0c3qOyrXbCcLRj8DQJORkhQSrp6j4CwIDDGaOJRYhP88VcD0+Ob7KfrcUbI02uySfI DheV+hzeEcSt7P7/cPOAjBriPqsf3J8Fq7NYBOik6Y2Ist4Qw3rXf3l5dDnL7dSJAnL/ LJ/kCALOWMVMlinw3yzsznxo2tqtG9cooFAFc680o8jw3h6LsxFYS3+5YpOPsjWNQiBk zJeiEG6lzJUuTAWQXE5mzaUKR+TWsQSVYEgTntUdzdstS7r6/3ZOp68d0qONvX/urrHK e93w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zODVNKHonSU3qYAwCTgn8Fil5BPscvRVeJSPN9g2BUw=; b=LDK/Vv6XV3Aafk8Ox3lLlv2KWSYR85tZMPSPZYdHN35nGFHWa0FMdFZ4AmvmPBYTfp Kzy8Gfu/HWeLalqbwOzAiA69KZsG5mKs0E9Y1lZyL7mqpRdPu/j3Iy96HOcQOP3kdS6P 2/lfERGJ7xU5WFmRqDG1F1+moaPYLVmy6tXeZ4H8t8pRDwxJ/OLv3BqaXAnJd8bZTell UTcqwUgKYRECWEWBFzhvhLiYcV2Y27R0z8RQdDD6EfAbfw9QpTPhFscHdaVQ32A4VH3W oFgah7Ph/OHt0qgs4aSQIK+xRlILOTotMDEPKj7p78Gh4kMYJgnb4NuTwtt4ytDjduBk P1cw== X-Gm-Message-State: AOAM530kuGvr5iHfR2wi+uZNuZQwCzhdhYRkJlS+dopQgUwuWIHjPsfj EPApGjjbh9KjF27bC/t4SF4= X-Received: by 2002:a05:600c:20b:: with SMTP id 11mr11824111wmi.112.1626365254261; Thu, 15 Jul 2021 09:07:34 -0700 (PDT) Received: from honeypot.lan ([2001:b07:6456:fd99:ced0:db1c:53e1:191e]) by smtp.googlemail.com with ESMTPSA id k13sm7446952wrp.34.2021.07.15.09.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 09:07:33 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Riccardo Mancini Subject: [PATCH 06/20] perf dso: fix memory leak in dso__new_map Date: Thu, 15 Jul 2021 18:07:11 +0200 Message-Id: <60bfe0cd06e89e2ca33646eb8468d7f5de2ee597.1626343282.git.rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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