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=1796386289; b=wPpCd6yrKQXSgSOVxZDgilc6eyWJyj+B0oZJyEi4DhLWlXKBm6ajtomkOKKGwfeD9zwu T1R5QN7h335EBQMYgZfvAGoyFqt4l9lI7dyx2pkZKw85K6hj0DDNT+fl+DbNKJDP4c6e+ g26Vgd95Rqu1cG7KdRu+KslPjEVL9o/0xL4ht2+c8QxPLWK0xKA5ES9uqggUugG1hHnTN O44QFKI/gk/O5witCEMrS3wAc89G8UjOLsZ+2FoZdr2dAUlMGvud3TSsLul3oCnRIgJkZ ZtOH57feyln/4Z2LD6yg/HS7exKvAn9URdWGgU6/SEE+qrA1BWi2D739NMoWzp7xkLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386289; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Mt9p6NdskmIoIhShMlECGqRJJypb2+KstWwBT89c0fw=; b=cELAEYhHaAMJoSGnFFHL5YIEOThv2IhX3orpJyz19KY5OhX/wbIrzlQbYtQlHlbnpTRa YoqVXNaKlCd6G1C3UtM+3OwGOUckfgb2+XwKFE3VUkWDpSZakJVkzKpExd9nssEy5Aase KTjU9JLWfXF0+NCc8tcJ5tKSCm/W/mlZ11k4m7cQ7vlMlp6dXxLENEBkvkrBz4Z+SikhP nwx7vvS2e9enQGRe4y9RW0nhczKx+IhMOB9a/Q4E4Ixujn4029g4z1pyBa2kfxQnYFQ0G o0QtGTrHzMD4/OL7ieIC5nbhdKZFzUUlC0GGQH46c+ogyqyPswvVa9Pe7ZkY+FUBncw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=XQh62CzU; 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 0E4C3606A322; Fri, 4 Dec 2026 12:11:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=XQh62CzU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A35C1F000CE; Fri, 4 Dec 2026 12:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386288; bh=Mt9p6NdskmIoIhShMlECGqRJJypb2+KstWwBT89c0fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XQh62CzU2tKHbpmxtF/gVQWFfgiJ+yJMuAiDfHOoGiQ7ebk5/Z0gGfLOLRNmLYzUV 3EFBTsJd4q7D1lVU2HxKUxxc2Urhy28NlPdsxd63SmAI2YNFfnHE2Ohl3s6DPr8C/+ G2u953+eK3DFxMJH6UqcH1fxUBDSoYHSFdTvLkJg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ijae Kim , Myeonghun Pak , Sashiko , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 6.6 0849/1167] memory: tegra: Shut down Tegra210 EMC timers before teardown Date: Fri, 4 Dec 2026 19:04:36 +0900 Message-ID: <20261204100724.235265482@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Myeonghun Pak [ Upstream commit c5f343c189aa30285e7c73dbf2f185720467794b ] The training and refresh timers can outlive the EMC state on removal or probe failure after clock attachment, causing use-after-free. Shut down both timers before detaching the clock provider and releasing the timing tables to wait for callbacks and prevent rearming. Initialize them before clock attachment, since set_rate() can start training. Fixes: 10de21148f7d ("memory: tegra: Add EMC scaling support code for Tegra210") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak Reported-by: Sashiko Closes: https://sashiko.dev/#/bug/linux-47538f77-fb50-4a06-b49b-92dbee8b538b Link: https://patch.msgid.link/20261015002852.2159841-1-mhun512@gmail.com Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- drivers/memory/tegra/tegra210-emc-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/memory/tegra/tegra210-emc-core.c b/drivers/memory/tegra/tegra210-emc-core.c index 3300bde47c137..ed304ea0386a0 100644 --- a/drivers/memory/tegra/tegra210-emc-core.c +++ b/drivers/memory/tegra/tegra210-emc-core.c @@ -1946,12 +1946,6 @@ static int tegra210_emc_probe(struct platform_device *pdev) config->same_freq = true; } - err = tegra210_clk_emc_attach(emc->clk, &emc->provider); - if (err < 0) { - dev_err(&pdev->dev, "failed to attach to EMC clock: %d\n", err); - goto release; - } - emc->clkchange_delay = 100; emc->training_interval = 100; dev_set_drvdata(emc->dev, emc); @@ -1963,6 +1957,12 @@ static int tegra210_emc_probe(struct platform_device *pdev) timer_setup(&emc->training, tegra210_emc_train, 0); + err = tegra210_clk_emc_attach(emc->clk, &emc->provider); + if (err < 0) { + dev_err(&pdev->dev, "failed to attach to EMC clock: %d\n", err); + goto release; + } + tegra210_emc_debugfs_init(emc); cd = devm_thermal_of_cooling_device_register(emc->dev, np, "emc", emc, @@ -1978,6 +1978,8 @@ static int tegra210_emc_probe(struct platform_device *pdev) detach: debugfs_remove_recursive(emc->debugfs.root); + timer_shutdown_sync(&emc->training); + timer_shutdown_sync(&emc->refresh_timer); tegra210_clk_emc_detach(emc->clk); release: of_reserved_mem_device_release(emc->dev); @@ -1990,6 +1992,8 @@ static int tegra210_emc_remove(struct platform_device *pdev) struct tegra210_emc *emc = platform_get_drvdata(pdev); debugfs_remove_recursive(emc->debugfs.root); + timer_shutdown_sync(&emc->training); + timer_shutdown_sync(&emc->refresh_timer); tegra210_clk_emc_detach(emc->clk); of_reserved_mem_device_release(emc->dev); -- 2.53.0