Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3675479pxv; Mon, 26 Jul 2021 09:11:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNKv7PRufzcBRpUIhTSCwlXIp9HJgIDcygrWYGC5ctrsb9zyz8dGqPH7YeuFSiJ7Pq3gQd X-Received: by 2002:a17:906:c7c2:: with SMTP id dc2mr18088567ejb.472.1627315861606; Mon, 26 Jul 2021 09:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315861; cv=none; d=google.com; s=arc-20160816; b=OiBYSKG85GaiqKxaaDirNtsatrVHIa5/zpF670VAf313M/3ATWr8T0/p03BM5xftVx FuQPVQYTgoLrrQpJMQklXxBDKcX4u3BjTR6f1WKuxbTVy4A8eqTRobawgyG2eCj7kU/D HjKMu+TdAi8thAAr0oFPat9LYTh9IkOugUo5nbi6KHLa+MYLn3/6VYFffA6EpAn26Aqa tmgPiC/5GV4Ptnanp2EOWpVVGGUUyNAVlnNJIm2rkiPuSwtGOP5rdvXJU/cIq47jCfES eciKY3QrwwiRg2qAh0koX+qRnG88pKMLfSho7ukczougu/9CTpyRo7XyPIaBE8LIFxnl jRoQ== 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=l313AqQK/rQ/fxuD46GoysnP8L+O24rElnREgGCO+Zw=; b=lh2b2Ib4464WbdOiEKa6YPKPsxp3H9Swvor2G2hbqKeErQs5GDKzezyPcnQQoZdyWG c4ibtSy78BlvTWYkHxChDN9y6OA6zoNQCGDTdS+UjQ5sSO2pIQKfe1eEGo76tYUzYnqz LplB79A6i6R4RLpo89g3bejXNIOrHLbnuQcm9DifSUPREIDRJPIyZ8ZI2nb6KCETGpEv VTS1C6kQP2u2PKBZpMLA+Vq+Q4SuD2UHA5PuKy0M6j7CfMSLQ/YNlzDfEIUGSlCDVkUh cwP2k7C+4jjuMBg2wEblzWsPiuSv7uT+cVUNVePK0FMpAwBpgfZSagrP1dTD1oPUZPVA nbqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HjaQhIT7; 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 f7si61276edy.123.2021.07.26.09.10.38; Mon, 26 Jul 2021 09:11:01 -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=HjaQhIT7; 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 S231857AbhGZP23 (ORCPT + 99 others); Mon, 26 Jul 2021 11:28:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:54388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237423AbhGZPPp (ORCPT ); Mon, 26 Jul 2021 11:15:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 867A761042; Mon, 26 Jul 2021 15:55:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314923; bh=W9qfR+V68/aK7vLmPpBak2aLgITJ1/4ojpMdzxEveuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HjaQhIT704O/P5CAn+9A+k9rtmA/ev1+qF5ZTCr66rGzlWcXyTRnnZ0OW019i7Api PQHdFl3dbkcxPPTIvZoQEu5+HMNGaQ1vt8spPi1HqyoADVYE9Xb5hQHEupihAmwb3E kPl0pYFnwRR6trRDROaOEMCXXVYf5rfekxYtNF9M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riccardo Mancini , Ian Rogers , Jiri Olsa , Krister Johansen , Mark Rutland , Namhyung Kim , Peter Zijlstra , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.4 020/108] perf map: Fix dso->nsinfo refcounting Date: Mon, 26 Jul 2021 17:38:21 +0200 Message-Id: <20210726153832.341314423@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 2d6b74baa7147251c30a46c4996e8cc224aa2dc5 ] ASan reports a memory leak of nsinfo during the execution of # perf test "31: Lookup mmap thread" The leak is caused by a refcounted variable being replaced without dropping the refcount. This patch makes sure that the refcnt of nsinfo is decreased whenever a refcounted variable is replaced with a new value. Signed-off-by: Riccardo Mancini Fixes: bf2e710b3cb8445c ("perf maps: Lookup maps in both intitial mountns and inner mountns.") Cc: Ian Rogers Cc: Jiri Olsa Cc: Krister Johansen Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lore.kernel.org/lkml/55223bc8821b34ccb01f92ef1401c02b6a32e61f.1626343282.git.rickyman7@gmail.com [ Split from a larger patch ] Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/map.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 571e99c908a0..1ae5c51a7035 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -214,6 +214,8 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, if (!(prot & PROT_EXEC)) dso__set_loaded(dso); } + + nsinfo__put(dso->nsinfo); dso->nsinfo = nsi; dso__put(dso); } -- 2.30.2