]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
octeontx2-af: npc: cn20k: Drop debugfs_create_file() error checks in init
authorRatheesh Kannoth <rkannoth@marvell.com>
Wed, 29 Apr 2026 02:27:14 +0000 (07:57 +0530)
committerJakub Kicinski <kuba@kernel.org>
Fri, 1 May 2026 01:50:15 +0000 (18:50 -0700)
debugfs is not intended to be checked for allocation failures the way other
kernel APIs are: callers should not fail probe or subsystem init because a
debugfs node could not be created, including when debugfs is disabled in
Kconfig. Replacing NULL checks with IS_ERR() checks is similarly wrong for
optional debugfs.

Remove dentry checks and -EFAULT returns from npc_cn20k_debugfs_init().
See:
https://staticthinking.wordpress.com/2023/07/24/
debugfs-functions-are-not-supposed-to-be-checked/

Cc: Dan Carpenter <error27@gmail.com>
Fixes: 528530dff56b ("octeontx2-af: npc: cn20k: add debugfs support")
Link: https://lore.kernel.org/netdev/adjNGPWKMOk3KgWL@stanley.mountain/
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Link: https://patch.msgid.link/20260429022722.1110289-3-rkannoth@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c

index 3debf2fae1a48e04e967eb0c01a10cb3738e2b64..6f13296303cb54d2e8ce30669104f153593d46bb 100644 (file)
@@ -249,34 +249,21 @@ DEFINE_SHOW_ATTRIBUTE(npc_defrag);
 int npc_cn20k_debugfs_init(struct rvu *rvu)
 {
        struct npc_priv_t *npc_priv = npc_priv_get();
-       struct dentry *npc_dentry;
 
-       npc_dentry = debugfs_create_file("mcam_layout", 0444, rvu->rvu_dbg.npc,
-                                        npc_priv, &npc_mcam_layout_fops);
+       debugfs_create_file("mcam_layout", 0444, rvu->rvu_dbg.npc,
+                           npc_priv, &npc_mcam_layout_fops);
 
-       if (!npc_dentry)
-               return -EFAULT;
+       debugfs_create_file("mcam_default", 0444, rvu->rvu_dbg.npc,
+                           rvu, &npc_mcam_default_fops);
 
-       npc_dentry = debugfs_create_file("mcam_default", 0444, rvu->rvu_dbg.npc,
-                                        rvu, &npc_mcam_default_fops);
+       debugfs_create_file("vidx2idx", 0444, rvu->rvu_dbg.npc,
+                           npc_priv, &npc_vidx2idx_map_fops);
 
-       if (!npc_dentry)
-               return -EFAULT;
+       debugfs_create_file("idx2vidx", 0444, rvu->rvu_dbg.npc,
+                           npc_priv, &npc_idx2vidx_map_fops);
 
-       npc_dentry = debugfs_create_file("vidx2idx", 0444, rvu->rvu_dbg.npc,
-                                        npc_priv, &npc_vidx2idx_map_fops);
-       if (!npc_dentry)
-               return -EFAULT;
-
-       npc_dentry = debugfs_create_file("idx2vidx", 0444, rvu->rvu_dbg.npc,
-                                        npc_priv, &npc_idx2vidx_map_fops);
-       if (!npc_dentry)
-               return -EFAULT;
-
-       npc_dentry = debugfs_create_file("defrag", 0444, rvu->rvu_dbg.npc,
-                                        npc_priv, &npc_defrag_fops);
-       if (!npc_dentry)
-               return -EFAULT;
+       debugfs_create_file("defrag", 0444, rvu->rvu_dbg.npc,
+                           npc_priv, &npc_defrag_fops);
 
        return 0;
 }