netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] can: silence remove_proc_entry warning
@ 2020-07-14  6:44 Zhang Changzhong
  2020-07-14 20:10 ` Oliver Hartkopp
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Changzhong @ 2020-07-14  6:44 UTC (permalink / raw)
  To: socketcan, mkl, davem, kuba; +Cc: linux-can, netdev, linux-kernel

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>
---
 net/can/proc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/can/proc.c b/net/can/proc.c
index e6881bf..077af42 100644
--- a/net/can/proc.c
+++ b/net/can/proc.c
@@ -471,6 +471,9 @@ void can_init_proc(struct net *net)
  */
 void can_remove_proc(struct net *net)
 {
+	if (!net->can.proc_dir)
+		return;
+
 	if (net->can.pde_version)
 		remove_proc_entry(CAN_PROC_VERSION, net->can.proc_dir);
 
@@ -498,6 +501,5 @@ void can_remove_proc(struct net *net)
 	if (net->can.pde_rcvlist_sff)
 		remove_proc_entry(CAN_PROC_RCVLIST_SFF, net->can.proc_dir);
 
-	if (net->can.proc_dir)
-		remove_proc_entry("can", net->proc_net);
+	remove_proc_entry("can", net->proc_net);
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] can: silence remove_proc_entry warning
  2020-07-14  6:44 [PATCH net-next] can: silence remove_proc_entry warning Zhang Changzhong
@ 2020-07-14 20:10 ` Oliver Hartkopp
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Hartkopp @ 2020-07-14 20:10 UTC (permalink / raw)
  To: Zhang Changzhong, mkl, davem, kuba; +Cc: linux-can, netdev, linux-kernel



On 14.07.20 08:44, Zhang Changzhong wrote:
> 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>

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Thanks!

> ---
>   net/can/proc.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/can/proc.c b/net/can/proc.c
> index e6881bf..077af42 100644
> --- a/net/can/proc.c
> +++ b/net/can/proc.c
> @@ -471,6 +471,9 @@ void can_init_proc(struct net *net)
>    */
>   void can_remove_proc(struct net *net)
>   {
> +	if (!net->can.proc_dir)
> +		return;
> +
>   	if (net->can.pde_version)
>   		remove_proc_entry(CAN_PROC_VERSION, net->can.proc_dir);
>   
> @@ -498,6 +501,5 @@ void can_remove_proc(struct net *net)
>   	if (net->can.pde_rcvlist_sff)
>   		remove_proc_entry(CAN_PROC_RCVLIST_SFF, net->can.proc_dir);
>   
> -	if (net->can.proc_dir)
> -		remove_proc_entry("can", net->proc_net);
> +	remove_proc_entry("can", net->proc_net);
>   }
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-14 20:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  6:44 [PATCH net-next] can: silence remove_proc_entry warning Zhang Changzhong
2020-07-14 20:10 ` Oliver Hartkopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).