From mboxrd@z Thu Jan 1 00:00:00 1970 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 C93DE1ED3E for ; Tue, 25 Jul 2023 11:22:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B72EC433C9; Tue, 25 Jul 2023 11:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690284151; bh=VowWUhe9JxkD6iG82r9Vu0Ecl5wkllRwo3nYHuSbFhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qk9OOlFiKNWVley6fYTOSB/XowVYRCfEnjeeY3hb+rt7ilErCOq7hiFdZgS+t+v3F w+Wa4iCcQvcY7OcK501O5fVIpOpGUwISJ97DlX3yy6xzo+eXF6HF1cnWAYFC1rcAMV 8TUflwLFvYNX2KUwXMfCY+00vEgWlGw1qXgoNPE0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, EJ Hsu , Haotien Hsu , Thierry Reding , Jon Hunter , Vinod Koul Subject: [PATCH 5.10 214/509] phy: tegra: xusb: Clear the driver reference in usb-phy dev Date: Tue, 25 Jul 2023 12:42:33 +0200 Message-ID: <20230725104603.525765729@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104553.588743331@linuxfoundation.org> References: <20230725104553.588743331@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: EJ Hsu commit c0c2fcb1325d0d4f3b322b5ee49385f8eca2560d upstream. For the dual-role port, it will assign the phy dev to usb-phy dev and use the port dev driver as the dev driver of usb-phy. When we try to destroy the port dev, it will destroy its dev driver as well. But we did not remove the reference from usb-phy dev. This might cause the use-after-free issue in KASAN. Fixes: e8f7d2f409a1 ("phy: tegra: xusb: Add usb-phy support") Cc: stable@vger.kernel.org Signed-off-by: EJ Hsu Signed-off-by: Haotien Hsu Acked-by: Thierry Reding Acked-by: Jon Hunter Link: https://lore.kernel.org/r/20230609062932.3276509-1-haotienh@nvidia.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/phy/tegra/xusb.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -556,6 +556,7 @@ static void tegra_xusb_port_unregister(s usb_role_switch_unregister(port->usb_role_sw); cancel_work_sync(&port->usb_phy_work); usb_remove_phy(&port->usb_phy); + port->usb_phy.dev->driver = NULL; } if (port->ops->remove)