From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 60D515326A6; Wed, 14 Oct 2026 13:31:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791984696; cv=none; b=jbSXEKCC1j5pAU/Djb9iWoWcnwQothlAB5kav8lZwaFqn3rLYd1ze/IvC90eLYrPCNZFKS6AbLNOzqjGf2BqY76cuJWz6UTPSrn5RHerSiMZA28yBlnZQpv/T6VxBhmA8PVr2AOxEfzKT/ciB9MNku+AE2lBKOycjx1ZrBFekpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791984696; c=relaxed/simple; bh=9L8KOZwL4/4iBVETH5ANqqtSQXUzA7maOFAqrnl0dxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=moic5rXL7GaHsC11blHuZ5swQtIdgCe39DzCSvE3DvLgggkOAI7pnz6xqlkV21rc4hFvSd9gpkDms+OdtauYHWA2JnPKbdyypKrov+EtD7guWwLCu44YeTjHHdiiGAkaLEKKnf0eH+zmnh9dYpT7MYdAbnxWWIKydvUSo05vIHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aHb0Zxf1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aHb0Zxf1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 059191F0089D; Wed, 14 Oct 2026 13:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791984691; bh=f3aboOe4jBL9DhwOlCp/yeX4fMdwzoUKtHuuVi6QUBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aHb0Zxf1MXRGv+V9Y852HhHp2U4bp6p1AD1refDWATArClw1GMFu7hsFtcrmEuXpe 3N4HBZwildXlPlsv1hRce5P7lX+1ZA5r/NcyUtbOYMoXXoNUNOzVqotcaCvOsxBFt5 QPfYVMNV37yedZbLEo3Y2Uj473DCXSQCe41Jp7lqHtJ4jH9ogdXP3OBQxLbgoBotoj 8gH5Gr8jMsGqahXyu0QypUmbKswmaAdCfAQJ5JztWPLyojbpeeHfXareAt6Oin4yvE CzlRseJMfjXV/bFzyQSiOn8d/tT7UzERSTar4eyhyJmxjMfg/qLHK6FBeKBSTxN5K8 W23l6TWmN0pxg== Received: from johan by xi.lan with local (Exim 4.99.5) (envelope-from ) id 1xGz4q-00000005qCY-2b3B; Wed, 14 Oct 2026 15:31:28 +0200 From: Johan Hovold To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Johan Hovold Cc: Dmitry Torokhov , Alan Stern , Mario Peter , driver-core@lists.linux.dev, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/3] driver core: take parent lock on deferred probe Date: Wed, 14 Oct 2026 15:31:08 +0200 Message-ID: <20261014133109.1392265-3-johan@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261014133109.1392265-1-johan@kernel.org> References: <20261014133109.1392265-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 a5b7abc10ff0..3c36a2128f88 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -154,6 +154,7 @@ struct kobject *virtual_device_parent(void); int bus_add_device(struct device *dev); void bus_probe_device(struct device *dev); +void bus_probe_device_deferred(struct device *dev); void bus_remove_device(struct device *dev); void bus_notify(struct device *dev, enum bus_notifier_event value); bool bus_is_registered(const struct bus_type *bus); diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 598e40d52f37..fd2257f73253 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -606,13 +606,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 subsys_private *sp = bus_to_subsys(dev->bus); struct subsys_interface *sif; @@ -630,6 +624,26 @@ void bus_probe_device(struct device *dev) subsys_put(sp); } +/** + * 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 974e04e79bda..f8f4c32b6c79 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -86,8 +86,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 @@ -121,7 +122,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.55.0