Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1176806pxb; Fri, 20 Nov 2020 03:13:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0ViDWWyxkkT+a/Dblddcr9A9aDcN3/oRoSuWTNOCE5r0oR69OGB42IOk/2GDC90WAGCSu X-Received: by 2002:aa7:df89:: with SMTP id b9mr35549542edy.335.1605870788477; Fri, 20 Nov 2020 03:13:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605870788; cv=none; d=google.com; s=arc-20160816; b=NYptE7kezEvLw+n1VaHOHhqn9UL/68WRHkZmgUTAR11AwdpMh6IbhKYiY2wEHs4cOQ jgXSURJ+lkHDkw5Hm8m7V1tf3VzM+L/Vm7V6BDihonxpdoZDbsy2Yq3UTdGo+F+DPK5B A0xvkAIop5BYwFmi97HSwCh8qqr9Sj9Eq4hLYmv3/SCZuqIgQD4/Pkl1GigoHJsVr7Tz YeSpglW2R0vL4+ZpxuQcwjZ9EIO1OWj7iSo/TZ85afMrmqbpXLrWoaXu+SqslXqkn0gO TNeofe9ST2zN4Lta8zwmerfsRIWz0ntYZlL9eKj1ZBUtHzRUso6Fv0umsobWD9pR0QIf 2jkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fg7LI9+FH+4cRjod7+d8OefiTGaiHA/bHbYHRFPHut0=; b=bfvU1WskM1XTxorRN4dAKF7OTi8rxNoXRvs7m29wlZzydgTTlw9PXFJFDs9N+vAFgz IUBbzvOurXcwXk4nY25ZzQIanVn3ZbjHnyZCj98owJqXMfEsz3rc7jrTbYKFpdu+Qzuf 9qrq7jlLFvscKxohnWRZxpk8w+99fge5UBFCd83JHl9zKSmb77RBGS09MaT9vkPkR1Ah AwVtuJeugltsEJTHxOsLn2kUwig7rM9tJuYNSuD9+ZzUYicFKOQ/GKw84+2A19tjg/nP NC+qDgW4tQMVS1sg22uIPPZAJWmJ6vUm66bQk7QVZMRIwnl9Z1MTgUzNoK71XM7YPakz TrXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LmKVLWTd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p21si1571948edw.573.2020.11.20.03.12.45; Fri, 20 Nov 2020 03:13:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LmKVLWTd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728463AbgKTLJw (ORCPT + 99 others); Fri, 20 Nov 2020 06:09:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:54852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728445AbgKTLGw (ORCPT ); Fri, 20 Nov 2020 06:06:52 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 40D792236F; Fri, 20 Nov 2020 11:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1605870411; bh=S64rmI05iX5oi/8hg3+BGqme9z9ceIDJUIXqWYB6Wgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LmKVLWTdG6SZMeq1Kilc2NiwslcgsEbXLyFCluFkQkR0ZyxaF5dq7VqDlFRx/cJuJ IJWx/13uVQO0l1lXqk22u4OhMqSskWv5XKhJywEzdqRfDzbjFp614L/iXw6mOY4765 mfSNSRpSjE1Q6WhT6gGlrwjRhevGVa9jMVEuo7LU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Changzhong , Oliver Hartkopp , Marc Kleine-Budde Subject: [PATCH 5.4 15/17] can: proc: can_remove_proc(): silence remove_proc_entry warning Date: Fri, 20 Nov 2020 12:03:42 +0100 Message-Id: <20201120104541.806260368@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201120104541.058449969@linuxfoundation.org> References: <20201120104541.058449969@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Changzhong commit 3accbfdc36130282f5ae9e6eecfdf820169fedce 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 Link: https://lore.kernel.org/r/1594709090-3203-1-git-send-email-zhangchangzhong@huawei.com Fixes: 8e8cda6d737d ("can: initial support for network namespaces") Acked-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- net/can/proc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- 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); }