From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387359; b=ygpVVCuBj0XBK/2jrzSVE9QK6JSL0zqsv6V6ugkJe1YIC4seg6CRzL01uOXj5BciOw8x NErpPALcSYJkTtnA6CEAhcj/0OqjjF8Cs8n10v47LEAuWVW979lUJAX7jpYyCTB6VItHd V3D3BnBWRrkm2wBADDY46aWfSelKGIXw7KCEmgcyvw3WJMUdG0lJ8HsE/KGpDRyBEKy5z qBR+Eg6JjV7XI0TjoO6e01YjOh7BJpCsc4SLll42sqz0mWVXr6zVtBwC8tJv8l4FPdj8t uZPVwdna2Kd6rOgZtLupyTuA48fGxbVKFnxVJ7UiKtzcc/oJpFo2nMiPVWYtO9vQGlg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387359; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=a+jY5eIRK1QRrUNTcMrq8Kdtpjgw/5Q4eKeFVYBni/E=; b=fQ06xYyktwVaMjvkUYikRYc2W0XY3xacwCMtZ3k7hNNcXuJc1wIwmJBEgjd4LhPJaVET 4UK7Siw9daptMjXp0Vabdl/4joAd12Odk2hOSr6rzyrt2ik7cJ93MAoTwxcqxNuRm+BeY GQyU5BLXqPXV8SLOqR3Gub2kQbKvY840dE127t37RJ/bz2IIli4vcAUDaKz8lRBwMPMEp cwNc4zeEifRvWpcGs6vB+0ORk9aXH9p+93w88UxqMjDW0+buZeaSMGIZkLT0Sxx2Hd+Om T8+3qpNEh+BVHGnwnsJTx4/o3Qj5Yj1nrsgmoN6f6Vk9zU9MRJUc5sifKjI3oNrCwSw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kdZaBVrf; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD4DF606A339; Fri, 4 Dec 2026 12:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kdZaBVrf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06A9F1F000C2; Fri, 4 Dec 2026 12:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387359; bh=a+jY5eIRK1QRrUNTcMrq8Kdtpjgw/5Q4eKeFVYBni/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kdZaBVrfgySpUd/EEmKD0NzepPZCQgmKJnOrdgPzY+KqxnzXjopREQ8Bugqpy4ZP5 M3WSiREwUFtXZRQipnjSpGmypk5ZvA/Qoto/jdOHSt1K212Rb25fnyU2yEiR2Goj+f UaqA8opiHh8qoqASrj/IMWGrGXp+bH2Y1VkQCsW0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mario Peter , Johan Hovold , Danilo Krummrich , Sasha Levin Subject: [PATCH 6.1 0212/1059] driver core: take parent lock on deferred probe Date: Fri, 4 Dec 2026 18:55:43 +0900 Message-ID: <20261204100649.766793464@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold [ Upstream commit 4059f8986c8f50102a04335cc1da4921dfd262d8 ] USB interfaces should be probed with the parent USB device lock held, but this is not honoured when probe is deferred. Add a new bus_probe_device_deferred() helper to handle deferred probe where the parent device lock is not held. Fixes: d1c3414c2a9d ("drivercore: Add driver probe deferral mechanism") Reported-by: Mario Peter Link: https://lore.kernel.org/20261007131514.1260696-1-mario.peter@leica-geosystems.com Cc: stable@vger.kernel.org # 3.4 Signed-off-by: Johan Hovold Link: https://patch.msgid.link/20261014133109.1392265-3-johan@kernel.org Signed-off-by: Danilo Krummrich [ sashal: Kept this tree's extern-style declaration block in base.h and added only the bus_probe_device_deferred() prototype, since the upstream context lines (bus_notify, bus_is_registered) don't exist here. ] Signed-off-by: Sasha Levin --- drivers/base/base.h | 1 + drivers/base/bus.c | 28 +++++++++++++++++++++------- drivers/base/dd.c | 7 ++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index b902d1ecc247f..062e99b891f44 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -129,6 +129,7 @@ struct kobject *virtual_device_parent(struct device *dev); extern int bus_add_device(struct device *dev); extern void bus_probe_device(struct device *dev); +extern void bus_probe_device_deferred(struct device *dev); extern void bus_remove_device(struct device *dev); extern int bus_add_driver(struct device_driver *drv); diff --git a/drivers/base/bus.c b/drivers/base/bus.c index b2d4c08848a8c..112e172eee1fd 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -471,13 +471,7 @@ int bus_add_device(struct device *dev) return error; } -/** - * bus_probe_device - probe drivers for a new device - * @dev: device to probe - * - * - Automatically probe for a driver if the bus allows it. - */ -void bus_probe_device(struct device *dev) +static void __bus_probe_device(struct device *dev) { struct bus_type *bus = dev->bus; struct subsys_interface *sif; @@ -495,6 +489,26 @@ void bus_probe_device(struct device *dev) mutex_unlock(&bus->p->mutex); } +/** + * bus_probe_device - probe drivers for a new device + * @dev: device to probe + * + * - Automatically probe for a driver if the bus allows it. + */ +void bus_probe_device(struct device *dev) +{ + __bus_probe_device(dev); +} + +void bus_probe_device_deferred(struct device *dev) +{ + if (dev->type && dev->type->need_parent_lock) + device_lock(dev->parent); + __bus_probe_device(dev); + if (dev->type && dev->type->need_parent_lock) + device_unlock(dev->parent); +} + /** * bus_remove_device - remove device from bus * @dev: device to be removed diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 71653ce21efab..dc44bc077238d 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -85,8 +85,9 @@ static void deferred_probe_work_func(struct work_struct *work) /* * This block processes every device in the deferred 'active' list. * Each device is removed from the active list and passed to - * bus_probe_device() to re-attempt the probe. The loop continues - * until every device in the active list is removed and retried. + * bus_probe_device_deferred() to re-attempt the probe. The loop + * continues until every device in the active list is removed and + * retried. * * Note: Once the device is removed from the list and the mutex is * released, it is possible for the device get freed by another thread @@ -120,7 +121,7 @@ static void deferred_probe_work_func(struct work_struct *work) device_pm_move_to_tail(dev); dev_dbg(dev, "Retrying from deferred list\n"); - bus_probe_device(dev); + bus_probe_device_deferred(dev); mutex_lock(&deferred_probe_mutex); put_device(dev); -- 2.53.0