From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 887D1202F71 for ; Sat, 15 Aug 2026 01:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786755972; cv=none; b=tVR9D0TguHl3SAocadBWCz+KKATNOqOj1brXSsWKjZcUG+YxQsT4PkBslBmtoq5tTwoyVn8mam7kkv9XjcFAtK7BeMzPW4uVV689L2zX1K9NIplSpAEoRIKvDpFDcK8fJddQlTu6EKwY9Hfd32LdxetEIe3nTuTq5+17v7cN+VA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786755972; c=relaxed/simple; bh=UbdAL1ouDxZG1e2QONEkezI0x5VGMw40T438//sPqJw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VcrVbSkHIs+77mqg4oxAcuOGu8yB4R/ZJ+5bRwsnIiXHynLMujH4XzD9SYMJS7rN+E8EzNiaJo4Ym7TjWoqWm/2tqjtNGsHUO9tqe+XoVy+0LMUo/1ODp2AmzbyvlgOh9o9H5LmuZW5mux2MaXcBNIuXAnY1c6yTUUf0TbtBMOE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZihN1M63; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZihN1M63" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65311F000E9; Sat, 15 Aug 2026 01:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786755971; bh=s3SBIDYZYqVz8IpQT0BUtfXzl58Q73xKJzr9I/vhl/0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=ZihN1M63NuX81H09rkVxzzxN5JJr86Vm5tp/gmeINFEg9xVRXYw8RbltJrAeaj4vx 32+3ID+3bUnvzlJXx640+0k9bmStX4GJkfgFzo3vTqjBzCFveaOW3/GZCJ70JNExaZ ZaYouRwnHh9BH7tNwgfdZ9AmtYdxIyB3mYxwMLiAzDG/bfSRb5ffhS5dCoLhgnVb5P YVgr74Dsbz0MGfXNs5fvYPL8AQMJ+X4qzNl1GJHR2TVkF52GE6AqghGLnXzltIhAQ2 NnwjIi01n3nm3c77tNfCMVnCYQ8sJoufSbyj+Gv760cuTkUeQ1WRwTWjfFb46C+ApV befRvykwnsP2g== Date: Sat, 15 Aug 2026 02:05:58 +0100 From: Jonathan Cameron To: Pengpeng Hou Cc: Conor Dooley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Paul Walmsley , Samuel Holland , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] cache: sifive_ccache: remove debugfs on driver register failure Message-ID: <20260815020558.2b4adbd9@jic23-huawei> In-Reply-To: <20260814081334.25771-1-pengpeng@iscas.ac.cn> References: <20260814081334.25771-1-pengpeng@iscas.ac.cn> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 14 Aug 2026 16:13:34 +0800 Pengpeng Hou wrote: > 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") > No blank lines in tag blocks. That breaks a bunch of tooling that runs on the kernel + tends to get you a message from one of the bots that is there to prevent this getting merged. > Assisted-by: Codex:gpt-5 > Signed-off-by: Pengpeng Hou > --- > Changes since v2: https://lore.kernel.org/all/20260623015527.32846-1-pengpeng@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) > > rc = platform_driver_register(&sifive_ccache_driver); > if (rc) > - goto err_unmap; > + goto err_remove_debugfs; > > of_node_put(np); > > return 0; > > +err_remove_debugfs: > +#ifdef CONFIG_DEBUG_FS It is stubbed out in debugfs.h so no need for guards here. So for that matter are the creation functions used in here. Ideally follow this patch with one removing ifdef CONFIG_DEBUG_FS from the driver. Both calls will return errors but that is fine as they aren't checked anyway (common for debugfs as a driver is almost never expected to fail probe just because debugfs isn't there). Note removing those guards should (feel free to check) result in no overhead as they dead code should get removed. Jonathan > + debugfs_remove_recursive(sifive_test); > +#endif > err_unmap: > iounmap(ccache_base); > err_node_put: