From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A80A3E833B; Tue, 30 Jun 2026 09:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782810592; cv=none; b=F598Wu6fccTwNBte/oJhJY0F8CUlJurB6IbaDNcbDpj0CHBOsYok1WHT78NnxgiSdRPCxfzNllQx0jZiWTRh6KNjyCzyr6MXM5XEhZ9r2Cug6kmHgJnSJMzyIi0zrJjSBM2HpRP6v36+V8h6F6QWyKOGBb0z2yILHllJpmLVFsE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782810592; c=relaxed/simple; bh=VIjE7YNDA1OBHVeMwyak+3YhjvbqzJB5tw9/6Wvq1Kc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=TRqujwoTgZ1SUVEGN7ZpIdWuLAN6zH9ZorH5fJ7b0dTuY63UhskCL+3mKS3hwlhdw3ZeUwE9q0f2cXhpz1Qq/kenI0XofcHSSJwRPe/8UNmXHcIZUX++ogz3gQ7mvj08DtEiFNcLIplnUmuRxbimVtercwlUYVzX5CTHIK+uWQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=hO/lFSxd; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=OTHHnbXa; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hO/lFSxd"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OTHHnbXa" Date: Tue, 30 Jun 2026 09:09:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1782810590; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BciDsbLRoX6Db1DX8F5qkNjxNxjUkQz1jLs+rveyX/A=; b=hO/lFSxd0v7soCLuhPUO3jGmbtx7H/afKPpTfp2vljQDc4oBXpRk6Sufa93gDBbShdAadh TYJI45moJro75zu31+wpDsa/OWHBoeEJOeBL0yrEvyDXLXVZ7UWru5wdJjSLoZzc2nTZbW WSbZgeJ9hnIRZGlk87I7eVUokQ/GJq5k9NglRZQxK6VAm2PuqXRo/OKu1qG48Hg6gwIuFD l9rll2h0jebzCcJ/I3389Pi0jA/MF4EAmb6vKlwA8Ac5hAyglSYpNdMhLJBC+bTTkwI/Tb Nq9JlXbBMrJERkOyVTQok733Fw0D6oS7XPsMxoSZ9D3AUaUfes/upMY4TTEEgw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1782810590; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BciDsbLRoX6Db1DX8F5qkNjxNxjUkQz1jLs+rveyX/A=; b=OTHHnbXa+xeBMPlwd2BL2cKIN7lreT3l/iMbVt9mpEVlpbV2XB/KMXBIU0UCVzE2TBufoe +GyFwcDw4bRHV/Bw== From: "tip-bot2 for Zide Chen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/x86/intel/uncore: Fix PCI PMU cleanup on setup failure Cc: Zide Chen , "Peter Zijlstra (Intel)" , Dapeng Mi , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260611160033.66760-2-zide.chen@intel.com> References: <20260611160033.66760-2-zide.chen@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178281058866.3843924.9902581873901488629.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the perf/core branch of tip: Commit-ID: 003267cb94e21d762eb72d6977d84f44f1705bb7 Gitweb: https://git.kernel.org/tip/003267cb94e21d762eb72d6977d84f44f17= 05bb7 Author: Zide Chen AuthorDate: Thu, 11 Jun 2026 09:00:26 -07:00 Committer: Peter Zijlstra CommitterDate: Tue, 30 Jun 2026 10:57:03 +02:00 perf/x86/intel/uncore: Fix PCI PMU cleanup on setup failure When uncore_pci_pmu_register() fails, pmu->boxes[die] is set to NULL before returning. In the uncore_pci_remove() path, this causes uncore_pci_pmu_unregister() to be skipped entirely, leaking pmu->activeboxes. In the uncore_bus_notify() path, uncore_pci_pmu_unregister() may still be called and must exit early when pmu->boxes[die] is NULL to avoid a NULL pointer dereference, and to ensure activeboxes is only decremented for a previously active box. Additionally, since pci_get_drvdata() returns NULL on registration failure, uncore_pci_remove() can no longer treat NULL drvdata as an indicator of an auxiliary PCI device. Remove the associated WARN_ON_ONCE(). Signed-off-by: Zide Chen Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Dapeng Mi Link: https://sashiko.dev/#/patchset/20260512233048.9577-1-zide.chen@intel.co= m?part=3D1 Link: https://patch.msgid.link/20260611160033.66760-2-zide.chen@intel.com --- arch/x86/events/intel/uncore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 7857959..b69b6a2 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c @@ -1183,6 +1183,7 @@ static int uncore_pci_pmu_register(struct pci_dev *pdev, /* First active box registers the pmu */ ret =3D uncore_pmu_register(pmu); if (ret) { + atomic_dec(&pmu->activeboxes); pmu->boxes[die] =3D NULL; uncore_box_exit(box); kfree(box); @@ -1248,6 +1249,9 @@ static void uncore_pci_pmu_unregister(struct intel_unco= re_pmu *pmu, int die) { struct intel_uncore_box *box =3D pmu->boxes[die]; =20 + if (!box) + return; + pmu->boxes[die] =3D NULL; if (atomic_dec_return(&pmu->activeboxes) =3D=3D 0) uncore_pmu_unregister(pmu); @@ -1272,7 +1276,6 @@ static void uncore_pci_remove(struct pci_dev *pdev) break; } } - WARN_ON_ONCE(i >=3D UNCORE_EXTRA_PCI_DEV_MAX); return; } =20