Skip to contentSkip to conversation

net:bonding:Fix error checking for debugfs_create_dir()

PATCH In review Wang Ming 3 participants 4 messages Jul 13, 2023 – Jul 14, 2023

Subsystems (3)
lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH 1/1 net:bonding:Fix error checking for debugfs_create_dir()

The debugfs_create_dir() function returns error pointers, it never returns NULL. Most incorrect error checks were fixed, but the one in bond_create_debugfs() was forgotten.

Fix the remaining error check.

Fixes 52333512701b ("net: bonding: remove unnecessary braces")
---
 drivers/net/bonding/bond_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_debugfs.c +1 -1
index 594094526648..d4a82f276e87 100644
@@ -88,7 +88,7 @@ void bond_create_debugfs(void)
 {
 	bonding_debug_root = debugfs_create_dir("bonding", NULL);
 
-	if (!bonding_debug_root)
+	if (IS_ERR(bonding_debug_root))
 		pr_warn("Warning: Cannot create bonding directory in debugfs\n");
 }
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Wang Ming

The debugfs_create_dir() function returns error pointers, it never returns NULL. Most incorrect error checks were fixed, but the one in bond_create_debugfs() was forgotten.

Fix the remaining error check.

Seems fine to me; note that almost nobody uses this as bonding
debugfs is hidden behind !CONFIG_NET_NS.

	-J
Quoted 22 lines
Fixes 52333512701b ("net: bonding: remove unnecessary braces")

---
drivers/net/bonding/bond_debugfs.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_debugfs.c +1 -1
index 594094526648..d4a82f276e87 100644
@@ -88,7 +88,7 @@ void bond_create_debugfs(void)
 {
 	bonding_debug_root = debugfs_create_dir("bonding", NULL);
 
-	if (!bonding_debug_root)
+	if (IS_ERR(bonding_debug_root))
 		pr_warn("Warning: Cannot create bonding directory in debugfs\n");
 }
 
Signature · 1 line
2.25.1
author Acked-by Jay Vosburgh
#2 lore raw

I think we can remove the check on it, don't you agree? Maybe I should resubmit a new patch Regards
Wang Ming

-----邮件原件-----
发件人: Jay Vosburgh <[email protected]>
发送时间: 2023年7月13日 23:49
收件人: 王明-软件底层技术部 <[email protected]>
抄送: Andy Gospodarek <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Yufeng Mo <[email protected]>; Guangbin Huang <[email protected]>; [email protected]; [email protected]; opensource.kernel <[email protected]> 主题: Re: [PATCH net v1] net:bonding:Fix error checking for debugfs_create_dir()

[????????? [email protected] ????????? https://aka.ms/LearnAboutSenderIdentification?????????????]

Quoted 7 lines · Wang Ming

The debugfs_create_dir() function returns error pointers, it never returns NULL. Most incorrect error checks were fixed, but the one in bond_create_debugfs() was forgotten.

Fix the remaining error check.

Seems fine to me; note that almost nobody uses this as bonding debugfs is hidden behind !CONFIG_NET_NS.

        -J
Quoted 22 lines
Fixes 52333512701b ("net: bonding: remove unnecessary braces")

---
drivers/net/bonding/bond_debugfs.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_debugfs.c +1 -2
index 594094526648..d4a82f276e87 100644
@@ -88,7 +88,7 @@ void bond_create_debugfs(void)  {
      bonding_debug_root = debugfs_create_dir("bonding", NULL);
 
-      if (!bonding_debug_root)
+      if (IS_ERR(bonding_debug_root))
              pr_warn("Warning: Cannot create bonding directory in 
 debugfs\n"); }
 
--

2.25.1

#3 lore raw

Re: [PATCH] net: bonding: Fix error checking for debugfs_create_dir()

In reply to Wang Ming
Quoted 9 lines

The debugfs_create_dir() function returns error pointers, it never returns NULL. Most incorrect error checks were fixed, but the one in bond_create_debugfs() was forgotten.

Fix the remaining error check.

Fixes 52333512701b ("net: bonding: remove unnecessary braces")

Would any other tag ordering be preferred?

How do you think about to use a subject like “[PATCH v2] net: bonding:
Fix an error check in bond_create_debugfs()”?

Regards,
Markus