From patchwork Tue Jan 10 17:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 13095405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE02C54EBE for ; Tue, 10 Jan 2023 17:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234199AbjAJRdE (ORCPT ); Tue, 10 Jan 2023 12:33:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234020AbjAJRc7 (ORCPT ); Tue, 10 Jan 2023 12:32:59 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D227059D09 for ; Tue, 10 Jan 2023 09:32:57 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id 3so6416509iou.12 for ; Tue, 10 Jan 2023 09:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OtDNURmcpxSd4X5CvSSnrMvtckUZqJr40ZSleDNYRZs=; b=PSSbxEopop8onxh/vKdHAcgs4yAkwL1+Or4bv4hn/RAv/zJ7mJeuy4G8Fvq6/C6wFM qu8sY5piesWyr/yiuxpF39tJvv4fSSU9ne6kGhXfTFlbDTZ00kIXNjUuxI/flIJMuFx7 +MdlVzkigYOHg8dZS1mM/rlisjpzcf0ju5PBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OtDNURmcpxSd4X5CvSSnrMvtckUZqJr40ZSleDNYRZs=; b=s4gunx2CL7YsS7OXO7ViJH+4LNZuI76bMGvmpZFhKrTb9hDTgxmyFyEJB3xlpKJpqF Pe4xMYLg7zArWoK32J6yxC+SWNnTO3TvOZ/DfNm+GYAK0X0fd3UuXpUqIRvIRGsT1RYY jUhJTJbMpnz59S6r9mhamcYBiMU7zaP/ekT1q4mRlRhoJXOTIShU7FS3cjbJY/NkhqaG JY2lEzdzVRYy/1n+onaCKOpNvILMJQbvMbjt35i2Eli1JenLWrL7m0heo90VHYIS01Ce ysV2aU2QcvQaay14IFMGrucxA0OO/JNii+1hKanq9NaIEVSkCYeLSorG4T+9AvAT8H9u m/Zg== X-Gm-Message-State: AFqh2krnEHwuIp1pt7p1SZcnClsIE4vLxGaF+hJDzo47eF5us7BbkfGB ORHMxS7Z0snxEu6KqHTBiX1gUg== X-Google-Smtp-Source: AMrXdXvpXvMe09tsbZT3n43/sy0SmBNBMcGmUZYebCUw7PUGrhsQko+s/6SqyEcy5wClUoFKEktBcg== X-Received: by 2002:a5e:8808:0:b0:6e2:af6e:3b58 with SMTP id l8-20020a5e8808000000b006e2af6e3b58mr46499475ioj.12.1673371977226; Tue, 10 Jan 2023 09:32:57 -0800 (PST) Received: from localhost (30.23.70.34.bc.googleusercontent.com. [34.70.23.30]) by smtp.gmail.com with UTF8SMTPSA id f3-20020a02a103000000b0039e91c28766sm1230804jag.167.2023.01.10.09.32.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Jan 2023 09:32:56 -0800 (PST) From: Matthias Kaehlcke To: Greg Kroah-Hartman Cc: Icenowy Zheng , stable@vger.kernel.org, Alexander Stein , linux-usb@vger.kernel.org, Johan Hovold , linux-kernel@vger.kernel.org, Stefan Wahren , Douglas Anderson , Matthias Kaehlcke , Ravi Chandra Sadineni Subject: [PATCH v2 1/2] usb: misc: onboard_hub: Invert driver registration order Date: Tue, 10 Jan 2023 17:32:52 +0000 Message-Id: <20230110172954.v2.1.I75494ebee7027a50235ce4b1e930fa73a578fbe2@changeid> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The onboard_hub 'driver' consists of two drivers, a platform driver and a USB driver. Currently when the onboard hub driver is initialized it first registers the platform driver, then the USB driver. This results in a race condition when the 'attach' work is executed, which is scheduled when the platform device is probed. The purpose of fhe 'attach' work is to bind elegible USB hub devices to the onboard_hub USB driver. This fails if the work runs before the USB driver has been registered. Register the USB driver first, then the platform driver. This increases the chances that the onboard_hub USB devices are probed before their corresponding platform device, which the USB driver tries to locate in _probe(). The driver already handles this situation and defers probing if the onboard hub platform device doesn't exist yet. Cc: stable@vger.kernel.org Fixes: 8bc063641ceb ("usb: misc: Add onboard_usb_hub driver") Link: https://lore.kernel.org/lkml/Y6W00vQm3jfLflUJ@hovoldconsulting.com/T/#m0d64295f017942fd988f7c53425db302d61952b4 Reported-by: Alexander Stein Signed-off-by: Matthias Kaehlcke Tested-by: Stefan Wahren --- (no changes since v1) drivers/usb/misc/onboard_usb_hub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/misc/onboard_usb_hub.c b/drivers/usb/misc/onboard_usb_hub.c index 94e7966e199d..db0844b30bbd 100644 --- a/drivers/usb/misc/onboard_usb_hub.c +++ b/drivers/usb/misc/onboard_usb_hub.c @@ -433,13 +433,13 @@ static int __init onboard_hub_init(void) { int ret; - ret = platform_driver_register(&onboard_hub_driver); + ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE); if (ret) return ret; - ret = usb_register_device_driver(&onboard_hub_usbdev_driver, THIS_MODULE); + ret = platform_driver_register(&onboard_hub_driver); if (ret) - platform_driver_unregister(&onboard_hub_driver); + usb_deregister_device_driver(&onboard_hub_usbdev_driver); return ret; }