Skip to content

Commit 3accbfd

Browse files
Zhang Changzhongmarckleinebudde
Zhang Changzhong
authored andcommitted
can: proc: can_remove_proc(): silence remove_proc_entry warning
If can_init_proc() fail to create /proc/net/can directory, can_remove_proc() will trigger a warning: WARNING: CPU: 6 PID: 7133 at fs/proc/generic.c:672 remove_proc_entry+0x17b0 Kernel panic - not syncing: panic_on_warn set ... Fix to return early from can_remove_proc() if can proc_dir does not exists. Signed-off-by: Zhang Changzhong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 8e8cda6 ("can: initial support for network namespaces") Acked-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent e5ab9aa commit 3accbfd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/can/proc.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ void can_init_proc(struct net *net)
462462
*/
463463
void can_remove_proc(struct net *net)
464464
{
465+
if (!net->can.proc_dir)
466+
return;
467+
465468
if (net->can.pde_stats)
466469
remove_proc_entry(CAN_PROC_STATS, net->can.proc_dir);
467470

@@ -486,6 +489,5 @@ void can_remove_proc(struct net *net)
486489
if (net->can.pde_rcvlist_sff)
487490
remove_proc_entry(CAN_PROC_RCVLIST_SFF, net->can.proc_dir);
488491

489-
if (net->can.proc_dir)
490-
remove_proc_entry("can", net->proc_net);
492+
remove_proc_entry("can", net->proc_net);
491493
}

0 commit comments

Comments
 (0)