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 F014736EA80 for ; Fri, 14 Aug 2026 08:13:44 +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=1786695231; cv=none; b=jklp8G0LLkIacWQrkFnl+agV1fHYgzyr/GkZ5U3/3evzgQv3fy3cr7ymutcEW+BnnIzRiQb7QULzw7+aItuDWwc8rds96FcB+i14ssOvP+3jmrAV69+KupXoikSeEveXOY1BklfByi7SZzhnaFA6koigYWQAyHbYr1dLXmSS44s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786695231; c=relaxed/simple; bh=r+A/jDLyAzt423ZuVxw1ODkUhvVd6V8TqKBYNSIAttk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BR3cRFda6CJpgigd8T7bXRwFtn2BApE3zQ46RqUeEImImf93LFlVuXXf7eR4jkH8VE9TjqbUkkZ7kRxz40EbLlcqHbEIoK+Ifwlo7nQtoYgenjygDayn0LALE23z4TpDptQAAdpYdQ9H2y152tZ+KxsOz3AdzJZGB1F1bFjM/t4= 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 qwCowABnPfEvzn5qbC+fBQ--.31470S2; Fri, 14 Aug 2026 16:13:36 +0800 (CST) From: Pengpeng Hou To: Conor Dooley , Jonathan Cameron Cc: Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Paul Walmsley , Samuel Holland , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Pengpeng Hou Subject: [PATCH v3] cache: sifive_ccache: remove debugfs on driver register failure Date: Fri, 14 Aug 2026 16:13:34 +0800 Message-ID: <20260814081334.25771-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: qwCowABnPfEvzn5qbC+fBQ--.31470S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw4DCF48AFW3Zr4UGFWrAFb_yoW8XF48pF W7ua4agr48uw429347A3WDZFyrCa9IqFy2934Uuw13Z398Ar1DXw18JFWYvF17ZF48Jw42 yr1ak3Z8AFW5CaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9I14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26r xl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E 8cxan2IY04v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFV Cjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWl x4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6r yUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j 6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJb IYCTnIWIevJa73UjIFyTuYvjfU5byZUUUUU X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ sifive_ccache_init() creates its debugfs entries before registering the platform driver. If platform_driver_register() fails, the current error path unmaps ccache_base but leaves the debugfs file and its write callback reachable. Remove the debugfs directory on that failure path before unmapping the controller registers. Fixes: c90847bcbfb6 ("cache: sifive_ccache: Partially convert to a platform= driver") Assisted-by: Codex:gpt-5 Signed-off-by: Pengpeng Hou --- Changes since v2: https://lore.kernel.org/all/20260623015527.32846-1-pengpe= ng@iscas.ac.cn/ - no source-code changes - rebase on current RISC-V sources - add the coding-assistant disclosure The error path was reviewed statically. It was not exercised on SiFive hardware. drivers/cache/sifive_ccache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/cache/sifive_ccache.c b/drivers/cache/sifive_ccache.c index 2acb8bdf06d5..3b7a78fc7feb 100644 --- a/drivers/cache/sifive_ccache.c +++ b/drivers/cache/sifive_ccache.c @@ -338,12 +338,16 @@ static int __init sifive_ccache_init(void) =20 rc =3D platform_driver_register(&sifive_ccache_driver); if (rc) - goto err_unmap; + goto err_remove_debugfs; =20 of_node_put(np); =20 return 0; =20 +err_remove_debugfs: +#ifdef CONFIG_DEBUG_FS + debugfs_remove_recursive(sifive_test); +#endif err_unmap: iounmap(ccache_base); err_node_put: --=20 2.50.1 (Apple Git-155)