Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3712789pxv; Mon, 26 Jul 2021 10:02:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlR0Xlp6XFP+K7cI/LrFfEh9TLga+MS6SMnkCLh+iKQwCd2XR/cB4wlQEV7hIn/S7t91Wb X-Received: by 2002:a05:6214:19e2:: with SMTP id q2mr19096853qvc.13.1627318926920; Mon, 26 Jul 2021 10:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318926; cv=none; d=google.com; s=arc-20160816; b=OSlBbsYf8GPT1ho5nTtTWV/Jh42Vj2twE+mkSlB/L/cp3LHItgvDwhe1gj5ldvnYtj IiHmOfzJDgasfa5T8g59Uts4XQOVsngqefJw6NQoKyvj/+kFN3BFGw2IyVvwOMf2stss ATkyZRjiM0ef7ZjXnXNAjIo5d919RwoObyU/80BRngc37JyeA9BXVrux5HA5Hnv1xLVs 6npWuzll16b6sdvvA9/KzVrXLMnuP9VX0zZgELV8yhWHUNMp6yu9HmJ4d47qv39tqMcf vGSrFzLHuFi4BRvMT3AiU1k2gEkAaDzOXyRSqjdZbXaTYPVWWIDQEKv9/fsd75OlWSkD 5PpA== 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=khCsJLBMud9du5HO+fQSbxibYVKlW2JFWo3j/mOZq90=; b=MLaf50InXqS/6fUx+Hu2fnr0B1peBafCmyjaJ0XKyiLq3eIG1qCEnCVBTeckm5zgj9 4HBLjQKrdVCk/sRvoA5vGkd+zCgv4fHmkkdwiPxhG/XdyW8TRWA9n/vKBvXBk+X/y9nn sVFkYXsqoqSoXHJA7PiunHsl56HfkdOnK7Boy006WJHXv5x+ksDaP6WVUBWiXnyCn42x 0XXhaNsd48M5sB3v8RO+FJt2sdCvV9195z+dqWFKxRGw5GPe48Pw9Cb6OZUal/hP+2ta bh0EHPuKXQOH3eWPE5CzYVM5bRReIMDuoW7w7lSWvYxg9yvEnkOKRVBHW5guXd9GZV57 zx+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L9S21XT8; 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 m7si206755qtp.84.2021.07.26.10.01.35; Mon, 26 Jul 2021 10:02:06 -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=L9S21XT8; 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 S237101AbhGZPiQ (ORCPT + 99 others); Mon, 26 Jul 2021 11:38:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:36408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237249AbhGZPV6 (ORCPT ); Mon, 26 Jul 2021 11:21:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E15D60240; Mon, 26 Jul 2021 16:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315346; bh=68cdLtV/VMPdbuQLhHDB61afRsRNxvLIy1SmyOgD5B4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9S21XT8gWMZO38GfKSy3AfeJmFIEXAfJMVgVfYbBxRTgv18UATCsRQXM/36cL2z2 48C5ND48OMG8jdIIoU/6Lxu7kZOHKkMeJDp1R2u7vVrz2DAzh5rOZwnZpqCCUUgI8D GqiLYphcEyjzjbAD/akOBkJNE2GpN1Lk8NWTvXhg= 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.10 033/167] perf inject: Fix dso->nsinfo refcounting Date: Mon, 26 Jul 2021 17:37:46 +0200 Message-Id: <20210726153840.501195475@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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 0967ebffe098157180a0bbd180ac90348c6e07d7 ] 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 when a refcounted variable is replaced with a new value. Signed-off-by: Riccardo Mancini Fixes: 27c9c3424fc217da ("perf inject: Add --buildid-all option") Cc: Ian Rogers Cc: Jiri Olsa 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/builtin-inject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c index 5320ac1b1285..ec7e46b63551 100644 --- a/tools/perf/builtin-inject.c +++ b/tools/perf/builtin-inject.c @@ -358,9 +358,10 @@ static struct dso *findnew_dso(int pid, int tid, const char *filename, dso = machine__findnew_dso_id(machine, filename, id); } - if (dso) + if (dso) { + nsinfo__put(dso->nsinfo); dso->nsinfo = nsi; - else + } else nsinfo__put(nsi); thread__put(thread); -- 2.30.2