From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796377412; b=MtnxwrYI58Fb5igtHli2HaiTuwZ7Sd3izcHnC899qEU12Lmgo1zq09DY1tg28s3tzViM a0HK2RhEHpHs1MMn3/BjM0YW5i33Z57e9N7KyFu0c/YdNHZDspK+QNl9VlfYH1cT5mKW6 Yie0lOI2Co5la3HzUccWcFciKjR9zeaEBHYwMvzpHJR07nEbxBweGYQCLQp1jlXMSOQdu QHxbOEwZzRd8Ebd3VfbWk/CZto/kT+HfwoJlttiTrfeL7ug1w6RzXT8vC7krRBa7MOyl9 QETQ8BgMHj5Fgkvjb7PqD/AW3TSQMn//mzmUrSvBpatuBP6Pb0gagVG4MrKeQWO2ifw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796377412; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=lW/X2qfn1ePFMhwGxwB4BMoJYVqJWBiaJXKa6ajFhMw=; b=3D/CU1oy3ya0W06T4UR5mZdh7cvHCMFqaOqb7+L+LLvkKPZMGU+81XhMlagepu8vmVXs WPsxx86ItsLK/jrneILmqvf4piCASTHaygokTjm3V51SeXrMjnAriGDz853o9W4sr/tQU HpQD8bqZcr4hG3sofNBBRGmXoFHMpBXGSNEuVdDtuRlPuuowG6gsOU4lsrFYxAfmV4sOj LJ+rWq8R21gBwQt1xeT9SPfwXRgpn7xkabZM7v7vrsgjvaolI2j5+T6nh563sjzF+AiNE iglnE1146H6mgVENhnQrva1UECRdN5I7pVKzph+/litjpVY8WFX51UheuNXlZS2+Tvg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XU0q65+T; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B116606A32C for ; Fri, 4 Dec 2026 09:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XU0q65+T Received: by smtp.kernel.org (Postfix) with ESMTPSA id 211391F000CE; Fri, 4 Dec 2026 09:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796377412; bh=lW/X2qfn1ePFMhwGxwB4BMoJYVqJWBiaJXKa6ajFhMw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=XU0q65+TDYbIF9Dpy4Ra/6I5U77HknqEcPHRN7LEzOWTt3foIJ9tWFBclXBQE1pHL OZR/5tKatU1IFND7Az89tpgVH60A0R3sat74DTF06U+RcIgUijQJA1iMecJMn2710j Ibx1EuUd0OagVlJp+fHOBdBN8GBJkRt0psUWSHtnkcZPIXq0CQnj6pZyy7d/eZw/Va Jesa4cVSXIWqbyW17maqm0R2Lx2w7OqJZA4NFY43ozI+vyQYUgYbRyTvx3sTA2rhgQ 7hJHRRipQo1IPKGFpyh4RE/yWlWXmPD1WoDbbWwzf1T5iiNS6VlyOIwoQ+lh+N9kiT EnkANTNTjaU7Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] usb: musb: mediatek: Release the usb_phy before unregistering it Reply-To: sashiko-reviews@lists.linux.dev To: "Lorenzo Ferrari" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261204092947.272427-1-loreferro01@gmail.com> References: <20261204092947.272427-1-loreferro01@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 09:43:31 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > mtk_musb_probe() registers a usb_phy_generic platform device and then > takes a reference to it with devm_usb_get_phy(). mtk_musb_remove() and > the probe error paths unregister that device by hand, which unbinds the > phy-generic driver and frees the struct usb_phy, but the devm reference > is only dropped later, when devres runs. devm_usb_phy_release() then > calls usb_put_phy() on freed memory, which dereferences > x->dev->driver->owner with a NULL driver. This happens whenever musb-mtk > is unbound or removed, and when its probe fails after > devm_usb_get_phy(). >=20 > Let devres do both steps, in the right order. Register the unregistration > of the usb_phy_generic device as a devm action right after creating it, > before devm_usb_get_phy(). devres releases resources in reverse order, so > the reference is dropped first and the device is unregistered afterwards. >=20 > This is the same fix as the one posted for the sunxi glue, where Rajan > Yadav also pointed out that mediatek.c has the same problem. >=20 > Fixes: 0990366bab3c ("usb: musb: Add support for MediaTek musb controller= ") > Cc: stable@vger.kernel.org > Reported-by: Rajan Yadav > Link: https://lore.kernel.org/all/20261110-musb-sunxi-unbind-v1-0-d821584= fc4a4@gmail.com/ > Assisted-by: Claude Opus 5.5 > Signed-off-by: Lorenzo Ferrari Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204092947.2724= 27-1-loreferro01@gmail.com?part=3D1