Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp744060rdb; Fri, 17 Nov 2023 11:18:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4bH+WgysJpUdf0ae0H2Tz8Les1h7s04+TuDXZxVSREJMNaQw3lUFm8MPyvXVqiwgRzQAE X-Received: by 2002:a05:6a21:1693:b0:187:ca9:3500 with SMTP id np19-20020a056a21169300b001870ca93500mr26157pzb.59.1700248705520; Fri, 17 Nov 2023 11:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700248705; cv=none; d=google.com; s=arc-20160816; b=aI5sJW8FnegX8zyUDdKhMAr8YES09H+Ad/UGQjyMm3xNHJoac7dOemruDLvJcwf6ju aYT/nFNNewCOhQk00OSfuqf8lx8SDuMiZ4+0DISOIlUous9j4Dkw8XHShzJPhDhHFJSy ggYzohd8EcJ/PrDWFEaTLGsYLMgZ/7wA9HyXsTfWlncgXzUdToWf8HADadBr42CSC1O8 /BmgmM6O/A4zUKvWTEiv0/gyP/RSOJ7GImLZqNs+6tMhGarOeHawIxwQ9BlJ+Z750n66 IVbKjFW2zKo7MNjLWx0iHBUnWSPE+L0fpFkm8z+MyGUuUtIfJY2lElycn8j6Gk5kzoYz Z7oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kYkliK5LLyBWsCelrZj1qHbRtpj0yIQa/B4ipiOpxIw=; fh=wu8dmBXP+QwXHCc1jsXa23E3fFN4ggbuzg2Wj3lNESI=; b=1B2abh1HUZMN7jXgP3Lvo2HNvDmKCpF5GrjI8Gbhh8V2KyJrWfzbf0+gmWsAMKTsB/ O/4gqm90F04XXOr+uGiIlTgIGIc3GzRRbzNDiVPS0h2ReZTdqRALOEae+iUXWuFa0MiL 2277GGs9FRNhLP1U/6MDgcDbUpK2vGqXS+OEsPL1ZNIALueIJdLJNnONh7TvhqIper4W qf7LyvWmQfPVJdWOm3ztBe8j62lC6mOhwgALKee7dhHynoWTPTSb2MSP4FLOptXok4Xt rohfrkXJ4zbQBPVq9hbH8YQkAP8+EGF1j323TCyiR8xsrOnVTkZOd0n/HfbM0IJ52JzC D+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UAL+5Y54; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u24-20020a631418000000b005c21d7d1126si172782pgl.843.2023.11.17.11.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 11:18:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UAL+5Y54; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E35EA808725F; Fri, 17 Nov 2023 11:17:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjKQTRj (ORCPT + 99 others); Fri, 17 Nov 2023 14:17:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjKQTRi (ORCPT ); Fri, 17 Nov 2023 14:17:38 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37310D4E for ; Fri, 17 Nov 2023 11:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700248654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kYkliK5LLyBWsCelrZj1qHbRtpj0yIQa/B4ipiOpxIw=; b=UAL+5Y54hXY9hevEGGz7s9uKB/TYyN0oH7yig03pQddhIMG1y8/5E/iGqF1vSxfdcb/Cgc bjNqtbM+DivNhRc20FbG9ECxEJJ82DGix3My38UrZ1Udbet/N0Hm8XbAy2MugCVEZzw5OZ 8/SGoZlhMci6Zu0P6TpV8CWeh+E7lL4= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-Nr4xD39LPfO4KEjdF95_LQ-1; Fri, 17 Nov 2023 14:17:33 -0500 X-MC-Unique: Nr4xD39LPfO4KEjdF95_LQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-778b3526240so265385485a.1 for ; Fri, 17 Nov 2023 11:17:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700248652; x=1700853452; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kYkliK5LLyBWsCelrZj1qHbRtpj0yIQa/B4ipiOpxIw=; b=KsEnkxfWracAKMII/bR1dbwTQBShixcJD5mc1axQwUnSRJarnpMVLaQrTHEuWQGPIq gIjTH7V+M8l3z0y4yF8zA4hPanXnw2V6lg/ympA52yIHBJGmEi4aFbz47nvxQS0gI12P 2rWrJGHLpgRpPnapEsD1xY03e24pWGuQhSAen5ai+YBv/xB2SmT1POMsz2b9zAzMkHuZ l03wtDR1yzVlxB70mmNG9sWbq9+Y6zTUQXjkt99ebWk6OeWXwFeLVTaK4aia3QPfxAbu EdVHpAUdRzJ24VHEosQpeh0mWhE5TpDWSt5mqwBjbf95etCA0sxQ22qImTCOSwU2II+6 PHmg== X-Gm-Message-State: AOJu0Yw2Z45gaOzgfJxH/BWeYujv6/dn2vEf+Cq4Wp1x3LllPs4PIXtS rtEl2v6sc74z17jUPbU13/SMofPyj9oIGMrKKMPSYvfB0hPswcIIqJjwsAEp3A2/p3oBMV+nQtP vNeBg7ClDIP987lsZDuw5+9Nj X-Received: by 2002:a05:620a:389e:b0:775:cf5f:8a81 with SMTP id qp30-20020a05620a389e00b00775cf5f8a81mr393654qkn.62.1700248652648; Fri, 17 Nov 2023 11:17:32 -0800 (PST) X-Received: by 2002:a05:620a:389e:b0:775:cf5f:8a81 with SMTP id qp30-20020a05620a389e00b00775cf5f8a81mr393636qkn.62.1700248652362; Fri, 17 Nov 2023 11:17:32 -0800 (PST) Received: from fedora ([2600:1700:1ff0:d0e0::49]) by smtp.gmail.com with ESMTPSA id pr13-20020a05620a86cd00b007770d47c621sm809192qkn.66.2023.11.17.11.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 11:17:32 -0800 (PST) Date: Fri, 17 Nov 2023 13:17:29 -0600 From: Andrew Halaney To: Johan Hovold Cc: Greg Kroah-Hartman , 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, Shawn Guo Subject: Re: [PATCH 3/3] USB: dwc3: qcom: fix ACPI platform device leak Message-ID: References: <20231117173650.21161-1-johan+linaro@kernel.org> <20231117173650.21161-4-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231117173650.21161-4-johan+linaro@kernel.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 17 Nov 2023 11:17:54 -0800 (PST) On Fri, Nov 17, 2023 at 06:36:50PM +0100, Johan Hovold wrote: > Make sure to free the "urs" platform device, which is created for some > ACPI platforms, on probe errors and on driver unbind. > > Compile-tested only. > > Fixes: c25c210f590e ("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot") > Cc: Shawn Guo > Signed-off-by: Johan Hovold Acked-by: Andrew Halaney > --- > drivers/usb/dwc3/dwc3-qcom.c | 37 +++++++++++++++++++++++++++++------- > 1 file changed, 30 insertions(+), 7 deletions(-) > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > index 0703f9b85cda..10fb481d943b 100644 > --- a/drivers/usb/dwc3/dwc3-qcom.c > +++ b/drivers/usb/dwc3/dwc3-qcom.c > @@ -767,9 +767,9 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev) > return ret; > } > > -static struct platform_device * > -dwc3_qcom_create_urs_usb_platdev(struct device *dev) > +static struct platform_device *dwc3_qcom_create_urs_usb_platdev(struct device *dev) > { > + struct platform_device *urs_usb = NULL; > struct fwnode_handle *fwh; > struct acpi_device *adev; > char name[8]; > @@ -789,9 +789,26 @@ dwc3_qcom_create_urs_usb_platdev(struct device *dev) > > adev = to_acpi_device_node(fwh); > if (!adev) > - return NULL; > + goto err_put_handle; > + > + urs_usb = acpi_create_platform_device(adev, NULL); > + if (IS_ERR_OR_NULL(urs_usb)) > + goto err_put_handle; > + > + return urs_usb; > > - return acpi_create_platform_device(adev, NULL); > +err_put_handle: > + fwnode_handle_put(fwh); > + > + return urs_usb; > +} > + > +static void dwc3_qcom_destroy_urs_usb_platdev(struct platform_device *urs_usb) > +{ > + struct fwnode_handle *fwh = urs_usb->dev.fwnode; > + > + platform_device_unregister(urs_usb); > + fwnode_handle_put(fwh); > } > > static int dwc3_qcom_probe(struct platform_device *pdev) > @@ -875,13 +892,13 @@ static int dwc3_qcom_probe(struct platform_device *pdev) > qcom->qscratch_base = devm_ioremap_resource(dev, parent_res); > if (IS_ERR(qcom->qscratch_base)) { > ret = PTR_ERR(qcom->qscratch_base); > - goto clk_disable; > + goto free_urs; > } > > ret = dwc3_qcom_setup_irq(pdev); > if (ret) { > dev_err(dev, "failed to setup IRQs, err=%d\n", ret); > - goto clk_disable; > + goto free_urs; > } > > /* > @@ -900,7 +917,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 clk_disable; > + goto free_urs; > } > > ret = dwc3_qcom_interconnect_init(qcom); > @@ -939,6 +956,9 @@ static int dwc3_qcom_probe(struct platform_device *pdev) > platform_device_del(qcom->dwc3); > } > platform_device_put(qcom->dwc3); > +free_urs: > + if (qcom->urs_usb) > + dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb); > clk_disable: > for (i = qcom->num_clocks - 1; i >= 0; i--) { > clk_disable_unprepare(qcom->clks[i]); > @@ -965,6 +985,9 @@ static void dwc3_qcom_remove(struct platform_device *pdev) > } > platform_device_put(qcom->dwc3); > > + if (qcom->urs_usb) > + dwc3_qcom_destroy_urs_usb_platdev(qcom->urs_usb); > + > for (i = qcom->num_clocks - 1; i >= 0; i--) { > clk_disable_unprepare(qcom->clks[i]); > clk_put(qcom->clks[i]); > -- > 2.41.0 > >