From nobody Sun Feb 8 20:30:23 2026 Received: from sg-1-103.ptr.blmpb.com (sg-1-103.ptr.blmpb.com [118.26.132.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D85DF23EAA1 for ; Fri, 12 Dec 2025 14:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.26.132.103 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765551404; cv=none; b=dWpVsKfApoSbpYo4yM7Cu/2Nooume6/ah9iEYfkEZ1ljEzzBttHRgl9DxLFAxy97FMrdPj5ln8a/2EqEGZZoEZm1Bv5tx/Zb3X1kg3uavL00CCMAFIg4NEI8TLmj5IedWfHzuCHAX9QuBl89ayr67BCMa6FGKzRiaaFvOxZGhu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765551404; c=relaxed/simple; bh=R3+VFqiY9OxXKrkggbvgi4CpQ3sg8fOv5hi3AHppWCM=; h=To:References:Cc:Message-Id:Content-Type:From:Date:In-Reply-To: Subject:Mime-Version; b=fVzF+GIcVPKi6MTMjWVGKgDO1Sz31/y0E9Z0JipfiWanY1NSp3EXpUzpP6iy8HaWh7VPeYNWZ9aFIoZgfPp/RwgHl3f5H3lmwtJRT/htxQ14WJx+Zp8jbtYNaBUSEXqimmmkD8TS/RWSEuHUGuSfpiBhdqqlh77uRh0KxOV2vZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=Qm12nDAG; arc=none smtp.client-ip=118.26.132.103 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="Qm12nDAG" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1765551389; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=I9fko49rlyRQO9najQQGMXmxO0V3/iBIPIKXkCh1tPc=; b=Qm12nDAG5WIKpL7kfC9JmwX+4ctnDu3Y7T2lgL3KrnD2k7m89jIJ1Mt1wNmyjwQAKlOAtV FtNOYn8rDHG8Aphk2wCILWztN17FaTICj5ljy4+kbOLnz73xi0ez5vZm6KtJHlTN6hLwWe iDZNFo+oG5vMqstaKnFcADzX7RzchkUoF3txJGvhoBoMiVN03V9GI/p8qDEm8NM1AczTL0 9KPB+KIeCAZMzg7AgRfF2Vogq+zIbtH/Q8QB8JGYgvhwfV4ehHcmrvorFgvUjopFMggwM8 6KKZP012plbqdu5dGX0CwHZvpaKfZjl/fRQhW3yeJwTs6ss1JljK2kd6LX+Jug== To: , , , , Content-Transfer-Encoding: quoted-printable References: <20251212133737.2367-1-guojinhui.liam@bytedance.com> Cc: , , , Message-Id: <20251212145528.2555-1-guojinhui.liam@bytedance.com> X-Original-From: Jinhui Guo From: "Jinhui Guo" Date: Fri, 12 Dec 2025 22:55:28 +0800 In-Reply-To: <20251212133737.2367-1-guojinhui.liam@bytedance.com> X-Mailer: git-send-email 2.17.1 X-Lms-Return-Path: Subject: [RESEND PATCH v2] PCI: Fix incorrect unlocking in pci_slot_trylock() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit a4e772898f8b ("PCI: Add missing bridge lock to pci_bus_lock()") delegates the bridge device's pci_dev_trylock() to pci_bus_trylock() in pci_slot_trylock(), but it forgets to remove the corresponding pci_dev_unlock() when pci_bus_trylock() fails. Before the commit, the code did: if (!pci_dev_trylock(dev)) /* <- lock bridge device */ goto unlock; if (dev->subordinate) { if (!pci_bus_trylock(dev->subordinate)) { pci_dev_unlock(dev); /* <- unlock bridge device */ goto unlock; } } After the commit the bridge-device lock is no longer taken, but the pci_dev_unlock(dev) on the failure path was left in place, leading to the bug. This yields one of two errors: 1. A warning that the lock is being unlocked when no one holds it. 2. An incorrect unlock of a lock that belongs to another thread. Fix it by removing the now-redundant pci_dev_unlock(dev) on the failure path. Fixes: a4e772898f8b ("PCI: Add missing bridge lock to pci_bus_lock()") Cc: stable@vger.kernel.org Signed-off-by: Jinhui Guo Reviewed-by: Dan Williams --- Hi, all Resent v2 to drop the Acked-by tag; no code changes. Sorry for the noise ag= ain. v1: https://lore.kernel.org/all/20251211123635.2215-1-guojinhui.liam@byteda= nce.com/ Changelog in v1 -> v2 - The v1 commit message was too brief, so I=E2=80=99ve sent v2 with more d= etail. - Remove the braces from the if (!pci_bus_trylock(dev->subordinate)) state= ment. Best Regards, Jinhui drivers/pci/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 13dbb405dc31..59319e08fca6 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5346,10 +5346,8 @@ static int pci_slot_trylock(struct pci_slot *slot) if (!dev->slot || dev->slot !=3D slot) continue; if (dev->subordinate) { - if (!pci_bus_trylock(dev->subordinate)) { - pci_dev_unlock(dev); + if (!pci_bus_trylock(dev->subordinate)) goto unlock; - } } else if (!pci_dev_trylock(dev)) goto unlock; } --=20 2.20.1