Subject: [PATCH 1/1] Net: bcm.c: Remove Subtree Instead of Entry

From: David Hunter <[email-masked]>
Date: Thu, 8 Aug 2024 16:26:58 -0400

Fix a warning with bcm.c that is caused by removing an entry. If the
entry had a process as a child, a warning is generated:

remove_proc_entry: removing non-empty directory 'net/can-bcm'...
WARNING: CPU: 1 PID: 71 at fs/proc/generic.c:717 remove_proc_entry
Call Trace:
remove_proc_entry
canbcm_pernet_exit
ops_exit_list

Instead of simply removing the entry, remove the entire subdirectory.
The child process will still be removed, but without a warning occurring.

This patch was compiled and the code traced with gdb to see that the
tree  was removed. The code was run to see that the warning was removed. 
In addition, the code was tested with the kselftest
net subsystem. No regressions were detected.

Signed-off-by: David Hunter <[email-masked]>
---
 net/can/bcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/can/bcm.c b/net/can/bcm.c
index 27d5fcf0eac9..fea48fd793e5 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1779,7 +1779,7 @@ static void canbcm_pernet_exit(struct net *net)
 #if IS_ENABLED(CONFIG_PROC_FS)
 	/* remove /proc/net/can-bcm directory */
 	if (net->can.bcmproc_dir)
-		remove_proc_entry("can-bcm", net->proc_net);
+		remove_proc_subtree("can-bcm", net->proc_net);
 #endif /* CONFIG_PROC_FS */
 }
 
-- 
2.34.1