From nobody Mon Oct 6 06:36:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2D91718786A; Thu, 24 Jul 2025 09:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; cv=none; b=K/iZ9Eyc5JV2mAgG1QG1yMiMQUCE8sHi4cTN4N5uFhr6jrC/C2XsOiw8lo/XQV3h6Lj4ri1R1UMyvNjdNAu2Bje1zQlqPpNElJtu6Pj/iS2CjmNG6XkCF5KTV6hHnrBzqkrFha7h7fJMeC13OvVzv9ojAfAU0niFZt1s1TDPCOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; c=relaxed/simple; bh=3sNEf2PDs0kL++sdmukPL9G4RGohNY9yUFg9AVXHkAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dFzQtjYS2bhfypt/dviGSK+Ke7ECuZj8uSr4QHz/2ZvXO6azultFXTfN6ye7N5Oj+aFnAX9fw+2Q+x2zsSMCctJJ7v721nkNMbwSxbqMDQQYSqo+ke/HZhzLQ8CrxTr+G/dYGPfH6wAsZIBE2OMStLEzRFjBlZ7K4dOyiWsfDeo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fS08fcVx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fS08fcVx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA9E3C4CEF5; Thu, 24 Jul 2025 09:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753348770; bh=3sNEf2PDs0kL++sdmukPL9G4RGohNY9yUFg9AVXHkAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fS08fcVxGx1Ibg9N9flueoBZGpeBYs85Sc0dRYV0NBhocrBE2CADmMcqQD+7S03mx EOyiAwCaJJPtJqcjOJ4/rEMom4tm7PsiBYgTO9kzODBKyYJ/Asc1q8tViQ/mB8AsP+ 5caCNcr9R3XISWKd7DtxfxQnwRIIgT7Z+ibkSNMiMUONtydDmFryuL4xY62td8QS6c KFRJS8JVT1aRx8gHjK1/uhq1vFcnTDQg9zaz2/enXkc7nRa9UOrE/d184uDfL+fKnr sm2Z2Bvw1iLimSrifgLauYkgAECurdKjUulhc3W1VEVa8JDbT7lKNdat6yWygVqKej 9g+qayZ6X9i/Q== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1ues6n-000000005Uv-2kta; Thu, 24 Jul 2025 11:19:25 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Thinh Nguyen , Bin Liu Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Li Jun Subject: [PATCH 1/5] usb: dwc3: imx8mp: fix device leak at unbind Date: Thu, 24 Jul 2025 11:19:06 +0200 Message-ID: <20250724091910.21092-2-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250724091910.21092-1-johan@kernel.org> References: <20250724091910.21092-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference to the dwc3 device taken by of_find_device_by_node() on probe errors and on driver unbind. Fixes: 6dd2565989b4 ("usb: dwc3: add imx8mp dwc3 glue layer driver") Cc: stable@vger.kernel.org # 5.12 Cc: Li Jun Signed-off-by: Johan Hovold --- drivers/usb/dwc3/dwc3-imx8mp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c index 3edc5aca76f9..bce6af82f54c 100644 --- a/drivers/usb/dwc3/dwc3-imx8mp.c +++ b/drivers/usb/dwc3/dwc3-imx8mp.c @@ -244,7 +244,7 @@ static int dwc3_imx8mp_probe(struct platform_device *pd= ev) IRQF_ONESHOT, dev_name(dev), dwc3_imx); if (err) { dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err); - goto depopulate; + goto put_dwc3; } =20 device_set_wakeup_capable(dev, true); @@ -252,6 +252,8 @@ static int dwc3_imx8mp_probe(struct platform_device *pd= ev) =20 return 0; =20 +put_dwc3: + put_device(&dwc3_imx->dwc3->dev); depopulate: of_platform_depopulate(dev); remove_swnode: @@ -265,8 +267,11 @@ static int dwc3_imx8mp_probe(struct platform_device *p= dev) =20 static void dwc3_imx8mp_remove(struct platform_device *pdev) { + struct dwc3_imx8mp *dwc3_imx =3D platform_get_drvdata(pdev); struct device *dev =3D &pdev->dev; =20 + put_device(&dwc3_imx->dwc3->dev); + pm_runtime_get_sync(dev); of_platform_depopulate(dev); device_remove_software_node(dev); --=20 2.49.1 From nobody Mon Oct 6 06:36:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3DEC7258CDC; Thu, 24 Jul 2025 09:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; cv=none; b=Y6Io/RSMUgti7kwL0zdNP9sDW+lioZ/o0t5jPpA8MZfpfp36AXUJVOit1lKYz3cI/gCTSQhKuF6eI0PnF5dRNoLV4K1Ak7lYXYH5X16ooVrSZ1NowyR7ExHk+g+P0Hq+E2LjC2Hb1osuPKd/R+W+xTSWLlILrUT3dq9GQlTCwOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; c=relaxed/simple; bh=Ur2Q4n8lOL4ygQwTq/C6e7qTaHDEJOyY+8hFLtDn3GM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IaGi/qXYIh9FAImD4e6ZVJ85pFtFo86/3ftAPr8cUahJsA2MxRrjzfv3C4pEMRUfvtdJOxZc2f+HZVq3zCePBkqgZ2+7LghVpBsUsQmDgVGs9NGJoFwwyUA285tKbEpPHRWEqIDVPjlZdKRexDnbl94SefCblP6Sv7+BxiFoLZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mvhb7kiJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mvhb7kiJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB002C4CEF8; Thu, 24 Jul 2025 09:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753348771; bh=Ur2Q4n8lOL4ygQwTq/C6e7qTaHDEJOyY+8hFLtDn3GM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mvhb7kiJRoY2ryS+f+xwdFn3JlJi2gdSfkAH97VXOGqmOFyNQD8K3/k99iwzZRm+u gAnCRjn4sTFSFqJrPeS/wGBcZthP/rRq9cQvZ/zu33tuQWyty/ocWTJNztgE16xfsX 6liCeJtyC4XclS8+D5ECZkNNaSZINEBcOy4uJ/t5xMEdD5PbhVOIqjgza/lVOEHbfg tW/wsFrQCX+MkqVa7VVWoRWAGQJ+XghE7iBJCw3kPkkHhUs1MB1KNbXGmS4H/muIkt mZQsGT8nDwnwa5yawnjvXz/6f1h1U4MGKB+Imq6iivZtVT6bF5nSPBuxGTXLGRvxsd TgVLkqWHrcZVg== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1ues6n-000000005Ux-3B7V; Thu, 24 Jul 2025 11:19:25 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Thinh Nguyen , Bin Liu Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 2/5] usb: dwc3: meson-g12a: fix device leaks at unbind Date: Thu, 24 Jul 2025 11:19:07 +0200 Message-ID: <20250724091910.21092-3-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250724091910.21092-1-johan@kernel.org> References: <20250724091910.21092-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the references taken to the child devices by of_find_device_by_node() during probe on driver unbind. Fixes: c99993376f72 ("usb: dwc3: Add Amlogic G12A DWC3 glue") Cc: stable@vger.kernel.org # 5.2 Cc: Neil Armstrong Signed-off-by: Johan Hovold Reviewed-by: Martin Blumenstingl --- drivers/usb/dwc3/dwc3-meson-g12a.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-mes= on-g12a.c index 7d80bf7b18b0..55e144ba8cfc 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -837,6 +837,9 @@ static void dwc3_meson_g12a_remove(struct platform_devi= ce *pdev) =20 usb_role_switch_unregister(priv->role_switch); =20 + put_device(priv->switch_desc.udc); + put_device(priv->switch_desc.usb2_port); + of_platform_depopulate(dev); =20 for (i =3D 0 ; i < PHY_COUNT ; ++i) { --=20 2.49.1 From nobody Mon Oct 6 06:36:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3DF28258CE7; Thu, 24 Jul 2025 09:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; cv=none; b=Slg+klEJ62VjIDqewK3bNzu7DywLlkuudqzqu+1owhovDdFRccysPJ6AcTExWqjQOnEXxk+cAbS9W2biz3kXQDpLc+LNQGXcTBfgoFMboSQ303BG8/DiKX57uFbtOhXLVxQMdvA3zClMLEyN9TzJRXtxylC3VMKskxdg1fJJdVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; c=relaxed/simple; bh=4QBXBq2TIpUKWHS0dOXuGcrJ+33C285poMFsrX5wwTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kgjw3zdsqUQ7uCYFGkAeDddLWd1nzcDkaSmqmmALLVJDz0wku5Ht6iMNWHvT0zbxyIvYWP8jkQT7IhpOW3MKyv+tOShho5kyLzOIp43bBXBclr+tmQ/mpLFnYPkWalAHZzg8fmUyKSDPswIeDfXm3PSMwuA77mQ9WuOHICfmaks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lD4hFQdo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lD4hFQdo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA2DFC4CEF9; Thu, 24 Jul 2025 09:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753348771; bh=4QBXBq2TIpUKWHS0dOXuGcrJ+33C285poMFsrX5wwTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lD4hFQdowc88sXR1TgcS7XG5ndJMfIitgPEMmTsz0cCJc4tWsisycukC9VS6ss0NT MIQmHBJhXF2fnufLG596NEWAWuq6ExVLDg1HbpuNARxR61xym8PTuageJWbIcY6B2m QyXZUF0MEd4N6dkanizu8zzRdniSMJqmMeyPurBmulYCpvl6+JTiY5EEZYXtOlBnLE JacPFdBdVZO6nWNq6XDh3bCyEIf2iFokhDcr2iYNzGoxcKKjyndryaJlrW4P95/UVU +OKvygmKzo1gYoDX5yqnGXalFw5PLHH8VIJ5OsM+l1jZcv0PU2u/cEPnI2rZR+9IRD zoFWRreT9l5+w== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1ues6n-000000005Uz-3YCG; Thu, 24 Jul 2025 11:19:25 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Thinh Nguyen , Bin Liu Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH 3/5] usb: gadget: udc: renesas_usb3: fix device leak at unbind Date: Thu, 24 Jul 2025 11:19:08 +0200 Message-ID: <20250724091910.21092-4-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250724091910.21092-1-johan@kernel.org> References: <20250724091910.21092-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference to the companion device taken during probe when the driver is unbound. Fixes: 39facfa01c9f ("usb: gadget: udc: renesas_usb3: Add register of usb r= ole switch") Cc: stable@vger.kernel.org # 4.19 Cc: Yoshihiro Shimoda Signed-off-by: Johan Hovold --- drivers/usb/gadget/udc/renesas_usb3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc= /renesas_usb3.c index 3e4d56457597..d23b1762e0e4 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -2657,6 +2657,7 @@ static void renesas_usb3_remove(struct platform_devic= e *pdev) struct renesas_usb3 *usb3 =3D platform_get_drvdata(pdev); =20 debugfs_remove_recursive(usb3->dentry); + put_device(usb3->host_dev); device_remove_file(&pdev->dev, &dev_attr_role); =20 cancel_work_sync(&usb3->role_work); --=20 2.49.1 From nobody Mon Oct 6 06:36:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9884B259CBA; Thu, 24 Jul 2025 09:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; cv=none; b=oMHjHxHp3mF2PYcs/Wnr0hcKoUdxiZ9GHWuquD+2029HPBZyMcyi864a82MKqxiOsuM5C+3N+63Fg7jW0tKVOGf7ZBjJOHhUj/E887Eqh3EF8DYTK4R3icdxG1+p/BjSBkKiytCtoxlmp/Xf27LjpI4lwaZ16JDGPdI3ut4/Ls8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; c=relaxed/simple; bh=heZubNRf2SjBNIuw2Atw10HonqmFi54G/HKy4mFRFIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZCs+S8MlgG17l9zqUIsiwQ7e0JlncJaTj5HIx9teG2nP5mnay6CLMYrYBeA7LUtjB3ZaqheROkWCgrcNKz5ydf2MI8rZiBQn1Q8VDEvQ23w3WfDw1nwSso3WmltRHd6vyiq0ArfNHtTe/DWyOFL2NF71sEnznrshXcaYIdV6+bI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CIx00lE9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CIx00lE9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F15A2C4CEFA; Thu, 24 Jul 2025 09:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753348771; bh=heZubNRf2SjBNIuw2Atw10HonqmFi54G/HKy4mFRFIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CIx00lE9oSnUaRBc7WEcZvhZSzTfjC3CH99QmbfDDQLZoKxZjJ/qfAMtf8d2lyriV n/te2CxDcO9q58DUXBsSXmtbkK4su6+Wa1PZ2MjuL7pOvlEpzkoGMkpQQ2+KsjYitx H09hPPDKUxo1D9gjUjs9XpNYqL/W+YmHVH8XVTjTktO8NGQIxFCVU0sYSFFg/bUxVH Y/qiOt+UmHGiADEvZDiLYuUrBYukCAScTEnWxRNQREYghINN4B+5Em/jMVLi7FLLcv O9d5zoOCTja7kwkdFwcwCzm0oH7MDrbGAgsWSTurKxFtByi5vxJ0mbc3bF+CDjKfRT NNgUwLsG+Cf5w== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1ues6n-000000005V1-3sbp; Thu, 24 Jul 2025 11:19:25 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Thinh Nguyen , Bin Liu Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Roger Quadros Subject: [PATCH 4/5] usb: musb: omap2430: fix device leak at unbind Date: Thu, 24 Jul 2025 11:19:09 +0200 Message-ID: <20250724091910.21092-5-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250724091910.21092-1-johan@kernel.org> References: <20250724091910.21092-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference to the control device taken by of_find_device_by_node() during probe when the driver is unbound. Fixes: 8934d3e4d0e7 ("usb: musb: omap2430: Don't use omap_get_control_dev()= ") Cc: stable@vger.kernel.org # 3.13 Cc: Roger Quadros Signed-off-by: Johan Hovold Reviewed-by: Kevin Hilman --- drivers/usb/musb/omap2430.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 2970967a4fd2..36f756f9b7f6 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -400,7 +400,7 @@ static int omap2430_probe(struct platform_device *pdev) ret =3D platform_device_add_resources(musb, pdev->resource, pdev->num_res= ources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err2; + goto err_put_control_otghs; } =20 if (populate_irqs) { @@ -413,7 +413,7 @@ static int omap2430_probe(struct platform_device *pdev) res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { ret =3D -EINVAL; - goto err2; + goto err_put_control_otghs; } =20 musb_res[i].start =3D res->start; @@ -441,14 +441,14 @@ static int omap2430_probe(struct platform_device *pde= v) ret =3D platform_device_add_resources(musb, musb_res, i); if (ret) { dev_err(&pdev->dev, "failed to add IRQ resources\n"); - goto err2; + goto err_put_control_otghs; } } =20 ret =3D platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err2; + goto err_put_control_otghs; } =20 pm_runtime_enable(glue->dev); @@ -463,7 +463,9 @@ static int omap2430_probe(struct platform_device *pdev) =20 err3: pm_runtime_disable(glue->dev); - +err_put_control_otghs: + if (!IS_ERR(glue->control_otghs)) + put_device(glue->control_otghs); err2: platform_device_put(musb); =20 @@ -477,6 +479,8 @@ static void omap2430_remove(struct platform_device *pde= v) =20 platform_device_unregister(glue->musb); pm_runtime_disable(glue->dev); + if (!IS_ERR(glue->control_otghs)) + put_device(glue->control_otghs); } =20 #ifdef CONFIG_PM --=20 2.49.1 From nobody Mon Oct 6 06:36:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 98F81259CBE; Thu, 24 Jul 2025 09:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; cv=none; b=EemD/nKrLBL+/K2IHu48coonHT7Ux2GaIZ3givzuk5oJ7xluyMtTsEJwAIZfB8dCLDy7TNQU3HzqXFzaCJXSZHznLMkiL+H437s4/vjFJsWrX9x8aST8irEFwMa6Emx34XZtIPiZDSrI19uKFp0m2fSqLqwjrIbh+91XTGjTzOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753348771; c=relaxed/simple; bh=NbStAABgbrjlf2qgwLuqJgJIAxPU8lYNEP9E56E4CUs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cEJ1g2eDvBd0Vhf8TRVOLNJmd1waLFpoigw+47dOcx36nS8bpdczKMOCSnoy3NdfcP6gCxf0+C5oOwYUiypPeJ+xRhBsuic+IBjiMfJBIYFTJg0WkLpNHrc1GJKWNxTqs/P2uSmZthCv7iapQxgp8zB+fwcq724DQWp4FtJZ3Gs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dfaC8/LD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dfaC8/LD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F25EC4CEF4; Thu, 24 Jul 2025 09:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753348771; bh=NbStAABgbrjlf2qgwLuqJgJIAxPU8lYNEP9E56E4CUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dfaC8/LDtZ/sjkj2J7raZ/DoaXymzy43nsmOcYsttXLpMZ9OD5wBna8lupayEav/E d7bvxqM5X3gN52+gl/9XZRyvvUqBy9MHZU2rOu2w6oGCxi9Acog+bfx2Bpsp3iNk6U aKWPEjjVYliVU1gz8VyBX2OC62CLNZspt1RMAT5jkjWCzVG1qWsXaS75qlaUCOfSl3 24Gg+4Bk9VziwhD8X3wQUxdSAYQ3iSMEEyi55EWREz4rDzcjIcPCqZx6AT+rdhAPxD OOeEwB2LhnNo7fJQhYZr1eUVgLIlj3n0z++QrhK6kAX/Kno3BEK4w09KVGqkEy4wOe MHneIvnwI2L0g== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1ues6o-000000005V4-02KN; Thu, 24 Jul 2025 11:19:26 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Thinh Nguyen , Bin Liu Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 5/5] usb: musb: omap2430: clean up probe error handling Date: Thu, 24 Jul 2025 11:19:10 +0200 Message-ID: <20250724091910.21092-6-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250724091910.21092-1-johan@kernel.org> References: <20250724091910.21092-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Using numbered error labels is discouraged (e.g. as it requires renumbering them when adding a new intermediate error path). Rename the error labels after what they do. While at it, drop the redundant platform allocation failure dev_err() as the error would already have been logged by the allocator. Signed-off-by: Johan Hovold Reviewed-by: Kevin Hilman --- drivers/usb/musb/omap2430.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 36f756f9b7f6..c35c07b7488c 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -318,13 +318,11 @@ static int omap2430_probe(struct platform_device *pde= v) =20 glue =3D devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); if (!glue) - goto err0; + return -ENOMEM; =20 musb =3D platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); - if (!musb) { - dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; - } + if (!musb) + return -ENOMEM; =20 musb->dev.parent =3D &pdev->dev; musb->dev.dma_mask =3D &omap2430_dmamask; @@ -349,15 +347,15 @@ static int omap2430_probe(struct platform_device *pde= v) =20 pdata =3D devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) - goto err2; + goto err_put_musb; =20 data =3D devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) - goto err2; + goto err_put_musb; =20 config =3D devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); if (!config) - goto err2; + goto err_put_musb; =20 of_property_read_u32(np, "mode", (u32 *)&pdata->mode); of_property_read_u32(np, "interface-type", @@ -380,7 +378,7 @@ static int omap2430_probe(struct platform_device *pdev) if (!control_pdev) { dev_err(&pdev->dev, "Failed to get control device\n"); ret =3D -EINVAL; - goto err2; + goto err_put_musb; } glue->control_otghs =3D &control_pdev->dev; } @@ -456,20 +454,19 @@ static int omap2430_probe(struct platform_device *pde= v) ret =3D platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err3; + goto err_disable_rpm; } =20 return 0; =20 -err3: +err_disable_rpm: pm_runtime_disable(glue->dev); err_put_control_otghs: if (!IS_ERR(glue->control_otghs)) put_device(glue->control_otghs); -err2: +err_put_musb: platform_device_put(musb); =20 -err0: return ret; } =20 --=20 2.49.1