Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp683332rdb; Fri, 17 Nov 2023 09:38:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQ3WxTmBrfN4zNtCCvxZKSLjEEMlpxtgQ9jmxrMz9SgqnMPc/D5aV7slvukbe7SIxw5dSN X-Received: by 2002:a05:6a00:b89:b0:6b1:b5c4:a8b0 with SMTP id g9-20020a056a000b8900b006b1b5c4a8b0mr114541pfj.23.1700242711457; Fri, 17 Nov 2023 09:38:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700242711; cv=none; d=google.com; s=arc-20160816; b=QGdNyqLj2BZm9hAK2pgkkNcdUx4UY/qtgmUH+n2P/HrunSOkhjs8I0xEQf050Biee3 U43XB/6WqdpFo95CL4w5iD7qfjb8n4zw2NfknLYyF2Ert+3IShz0ymI0XvMaicBeQCzL 3v7OHtyeMMYL696Gd6DJEqgKzhJF786BMMCN6PegfjzP4jlbcMwodyPg8OI/lc1O0D/c OMyO9LWbKd4N/2bj305ge1KVR9kGTwf+ucUg7i5wjBvye6jE8G8Tn3MJ3KtomhgsIMGm P8HXKzKGjh6ytHMq95JkExpkS8OQA1OHCVst/BSf/O0P2tbjoxmrpzl9pru2Qh1utIag i0iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ooaml9mHUgDx1PwS0Qh6e4kMQAzOAlJnhijQkCX9yJA=; fh=XWZS1/O2R5UEzIZ2Ta+pFh9orQgTyjtUsNQv7S84N3k=; b=yU0MRO5K//3Y37pAPMvL6J1ds9AI23ar3gFQmffVAzE6VKZOU/z6UnAnONsIgmtVSC pMx/v7OmjzwIZi/hYmg3eGrm2QGPuwCZBH/Jnf33TTJLz/TazJSZ6a8czliKap0uve6a tSRFDH87h/9dQxQHgqC6L50NWD+uvTrY9XwtMqZ7zR6W+NEDQlWPzLPSbW33II7b+9wq oH572L6tDrqhz+lN/oe7dvigPxr7rEJVXnmcCoQdjsvAoLL4ywx4LPZITMLrHU2awnja y8BvBhtO506t3aTvdOBoCppBAXozQrj7KToYZ+QQfE9y/xYkwnZtyuIbkpII1f2H398X uhug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GQQoKGq4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bz14-20020a056a02060e00b005bce8cfb592si2578551pgb.245.2023.11.17.09.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 09:38:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GQQoKGq4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 13DA1824E513; Fri, 17 Nov 2023 09:38:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346185AbjKQRiO (ORCPT + 99 others); Fri, 17 Nov 2023 12:38:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346175AbjKQRiN (ORCPT ); Fri, 17 Nov 2023 12:38:13 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C35FC10EC; Fri, 17 Nov 2023 09:38:09 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 649F4C433C7; Fri, 17 Nov 2023 17:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700242689; bh=ljA1LE+xModnv/rFyY3a5h9MWPkAGHDKsjJTHgO6Jy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GQQoKGq4PKII8w2kZ9Ui7sAHGZegFoJcfpW/GHAyTwpuVMG9tnclFUbHWiSm/0jPS jMYGeQiD6IVDGIdocJqgUB3neWjKtoXx/KbOxLWxp5enmdF9uiKhkPKu2c5HP+fekB neRi7u3uTuPmobUwtQ6Q0yFjiS50Ho94SI11l2OcVaq8gG3fCLSTWM8i8PUp4azVm+ zIfUGL5PYZsQAvD5C2KsZJcjrx9Nc1qsg0ggh+NelKSTzJkVHPANNlSlYHTpMww1W7 UbTRjGgtlFesn2oDP0kRLvHHElGpuilAYHVBdtAp3q0oTwqKEzDoa20KBEmYKMdTvf GLm2FKbJ6dhpA== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1r42nF-0005Vq-0f; Fri, 17 Nov 2023 18:38:13 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Thinh Nguyen , Krishna Kurapati PSSNV , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Christophe JAILLET , Lee Jones Subject: [PATCH 1/3] USB: dwc3: qcom: fix resource leaks on probe deferral Date: Fri, 17 Nov 2023 18:36:48 +0100 Message-ID: <20231117173650.21161-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231117173650.21161-1-johan+linaro@kernel.org> References: <20231117173650.21161-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 17 Nov 2023 09:38:25 -0800 (PST) The driver needs to deregister and free the newly allocated dwc3 core platform device on ACPI probe errors (e.g. probe deferral) and on driver unbind but instead it leaked those resources while erroneously dropping a reference to the parent platform device which is still in use. For OF probing the driver takes a reference to the dwc3 core platform device which has also always been leaked. Fix the broken ACPI tear down and make sure to drop the dwc3 core reference for both OF and ACPI. Fixes: 8fd95da2cfb5 ("usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()") Fixes: 2bc02355f8ba ("usb: dwc3: qcom: Add support for booting with ACPI") Fixes: a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver") Cc: stable@vger.kernel.org # 4.18 Cc: Christophe JAILLET Cc: Lee Jones Signed-off-by: Johan Hovold --- drivers/usb/dwc3/dwc3-qcom.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 3de43df6bbe8..00c3021b43ce 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -758,6 +758,7 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev) if (!qcom->dwc3) { ret = -ENODEV; dev_err(dev, "failed to get dwc3 platform device\n"); + of_platform_depopulate(dev); } node_put: @@ -899,7 +900,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) if (ret) { dev_err(dev, "failed to register DWC3 Core, err=%d\n", ret); - goto depopulate; + goto clk_disable; } ret = dwc3_qcom_interconnect_init(qcom); @@ -934,7 +935,8 @@ static int dwc3_qcom_probe(struct platform_device *pdev) if (np) of_platform_depopulate(&pdev->dev); else - platform_device_put(pdev); + platform_device_del(qcom->dwc3); + platform_device_put(qcom->dwc3); clk_disable: for (i = qcom->num_clocks - 1; i >= 0; i--) { clk_disable_unprepare(qcom->clks[i]); @@ -957,7 +959,8 @@ static void dwc3_qcom_remove(struct platform_device *pdev) if (np) of_platform_depopulate(&pdev->dev); else - platform_device_put(pdev); + platform_device_del(qcom->dwc3); + platform_device_put(qcom->dwc3); for (i = qcom->num_clocks - 1; i >= 0; i--) { clk_disable_unprepare(qcom->clks[i]); -- 2.41.0