Skip to content

Commit 7ae6f2d

Browse files
Zhang Changzhonggregkh
authored andcommitted
can: proc: can_remove_proc(): silence remove_proc_entry warning
commit 3accbfd upstream. 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 <zhangchangzhong@huawei.com> Link: https://lore.kernel.org/r/1594709090-3203-1-git-send-email-zhangchangzhong@huawei.com Fixes: 8e8cda6 ("can: initial support for network namespaces") Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1527ab7 commit 7ae6f2d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/can/proc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ void can_init_proc(struct net *net)
471471
*/
472472
void can_remove_proc(struct net *net)
473473
{
474+
if (!net->can.proc_dir)
475+
return;
476+
474477
if (net->can.pde_version)
475478
remove_proc_entry(CAN_PROC_VERSION, net->can.proc_dir);
476479

@@ -498,6 +501,5 @@ void can_remove_proc(struct net *net)
498501
if (net->can.pde_rcvlist_sff)
499502
remove_proc_entry(CAN_PROC_RCVLIST_SFF, net->can.proc_dir);
500503

501-
if (net->can.proc_dir)
502-
remove_proc_entry("can", net->proc_net);
504+
remove_proc_entry("can", net->proc_net);
503505
}

0 commit comments

Comments
 (0)