From nobody Tue Sep 29 00:45:21 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9511240B103 for ; Fri, 14 Aug 2026 07:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786693874; cv=none; b=eAqqWOgIFt7hQectSbrngY5oDZpqFE55b6rbIMu857xJQGKLHPqgcuY+E12iK6kzlRcEbkhEw93lyk33Kd2gFb/FX/3vQosCTWkCBK1oRP4jN4t3CpYZdwauu1SR77yQnQ5tiRdIH0qDwIENWsD2JIWTHEOU3VgDRmyEkq16Jw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786693874; c=relaxed/simple; bh=0CDqGFDeSCW88mlZ/HNgplFQEdjJBzsigMbENsW5Nvo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Q/xIlGkoxvluRUElKzztI3QSskgZYbi/wny66onVqYWObp6S4ZOHy/yhJw8f1kZwvZiEaQGeiRjBAeyl5cFck5WpG6a2Wper01yIp0TNMyAmwpU/vIyBZ1O8MlrCNOGq+/1uM+RBsmG0TwOuu1yQVV0vEHBB7wo2L1q/O1Hh5jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost.localdomain (unknown [111.196.241.250]) by APP-01 (Coremail) with SMTP id qwCowAD3y+_nyH5qYF+eBQ--.22171S2; Fri, 14 Aug 2026 15:51:03 +0800 (CST) From: Pengpeng Hou To: Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Pengpeng Hou Subject: [PATCH v2] soc: mediatek: mtk-svs: remove the debugfs tree on teardown Date: Fri, 14 Aug 2026 15:51:03 +0800 Message-ID: <20260814075103.10392-1-pengpeng@iscas.ac.cn> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowAD3y+_nyH5qYF+eBQ--.22171S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXF4fZry3XF1fXr4xuFykZrb_yoW5Xw1xpa nYk3WrKry8Jr17GFWfAa17X3WfurZ7W3y7uryxW3s7Z3sxAr1rXr97tFWYqrZaqFykGa47 ZF18tryUCa15KFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkC14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4U MIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUe0PSUU UUU X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ svs_create_debug_cmds() publishes a debugfs tree whose private data points at devm-managed platform and bank state. Partial creation failure and device teardown currently leave entries referring to state that is about to be released. Remove the complete tree on partial failure and register a devm action after successful creation. The debugfs full-proxy lifetime rules keep active file operations synchronized with removal, and the devm action runs before the managed SVS state is freed. Fixes: 13f1bbcfb582 ("soc: mediatek: SVS: add debug commands") Assisted-by: Codex:gpt-5 Signed-off-by: Pengpeng Hou --- Changes since v1: https://lore.kernel.org/all/20260616151406.92529-1-pengpe= ng@iscas.ac.cn/ - remove the complete debugfs tree after partial creation failure - register devm teardown for successful probes - recheck open-file lifetime against the debugfs full proxy The debugfs and devm lifetimes were reviewed statically; bind/unbind was not exercised on MediaTek hardware. drivers/soc/mediatek/mtk-svs.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 99edecb204f2..7ebc680627c9 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -172,6 +172,11 @@ static DEFINE_SPINLOCK(svs_lock); } =20 #define svs_dentry_data(name) {__stringify(name), &svs_##name##_debug_fops} + +static void svs_remove_debug_cmds(void *data) +{ + debugfs_remove(data); +} #endif =20 /** @@ -887,7 +892,7 @@ static int svs_create_debug_cmds(struct svs_platform *s= vsp) if (IS_ERR(file_entry)) { dev_err(svsp->dev, "cannot create %s/%s: %ld\n", d, svs_entries[i].name, PTR_ERR(file_entry)); - return PTR_ERR(file_entry); + goto err_remove_debugfs; } } =20 @@ -901,7 +906,8 @@ static int svs_create_debug_cmds(struct svs_platform *s= vsp) if (IS_ERR(svsb_dir)) { dev_err(svsp->dev, "cannot create %s/%s: %ld\n", d, svsb->name, PTR_ERR(svsb_dir)); - return PTR_ERR(svsb_dir); + file_entry =3D svsb_dir; + goto err_remove_debugfs; } =20 for (i =3D 0; i < ARRAY_SIZE(svsb_entries); i++) { @@ -912,12 +918,17 @@ static int svs_create_debug_cmds(struct svs_platform = *svsp) dev_err(svsp->dev, "no %s/%s/%s?: %ld\n", d, svsb->name, svsb_entries[i].name, PTR_ERR(file_entry)); - return PTR_ERR(file_entry); + goto err_remove_debugfs; } } } =20 - return 0; + return devm_add_action_or_reset(svsp->dev, svs_remove_debug_cmds, + svs_dir); + +err_remove_debugfs: + debugfs_remove(svs_dir); + return PTR_ERR(file_entry); } #endif /* CONFIG_DEBUG_FS */ =20 --=20 2.50.1 (Apple Git-155)