Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1174415pxb; Fri, 20 Nov 2020 03:09:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGXJQQ02uBxmi04IPO8nOE1ndItf01sRVJI1MLQBjPa90UVQD8Hqc+UY20i/NjgSBSglj2 X-Received: by 2002:a17:906:1744:: with SMTP id d4mr119015eje.176.1605870568045; Fri, 20 Nov 2020 03:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605870568; cv=none; d=google.com; s=arc-20160816; b=MAisK0yoYQnZLQRd8ASd01BuMCoHoBay0E5m3cWuJCwChVClIYfGpqcniMfFcmDLza uRpwW/tpDqbKjqWdGUMdSm4+EvvSzwEnqvyoIK1JwVJmsLWWJiJT4ClaHeyeNsvu70fN GpBrzfCAkHvI7HO9Wu1hkUdhIZzC1qmQTnagZ3phAkqeecuvP88FROQ8csxicHFV0gJM EfOlnZYA8sRmRgEbCQ7m4C5dDgkJtddAC2lDBvyp+YRtyWgAyDlucFVlUcuTu+TfOtcw Udi5LG7GXTi/nqhy5I+Z5U2dZfhS3fFIIOiAS5jXxv2itOky1udK9LO731GlTE3NeMwD pIBQ== 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=zvY8H5MH3QQ7hRcDdoZhH0mkbXr7F+w1GWQF2ZO1/SU=; b=qOZXbZx5x4D52X1KTc5gY5C6iYDf2F1m/BntCzwtUZwyYpBHKTCrjDWPqVpypyokbm E8Mgtso84w6Z9Xh9gmqiOigwPz4xcULoDlJ0tAgXkZ+hFzIzpL0KMlcN/rhfPGKrlVwZ nFf3sorQLyHiuI6Jk6AwsNDGD24t0jaroWrTaAQX3sU2psWJ6MQoZZTuG+lxehdYsaVx vm0qjkZfZMnVP6vjk0EYBkRlCk+1cRBx//geImtI7D4NT0EQ+kPaVkfbfat7ePdKzMt1 dCpbpGq48M2T+bI/j1TdF1jIsYtw6sGM4lRTfvMIX/SJKI7LtoWKAAfN6qklwl9b0E9J UAdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xjqzmHQI; 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 w14si998236ejz.314.2020.11.20.03.09.02; Fri, 20 Nov 2020 03:09:28 -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=xjqzmHQI; 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 S1726541AbgKTLGe (ORCPT + 99 others); Fri, 20 Nov 2020 06:06:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:54134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728383AbgKTLGX (ORCPT ); Fri, 20 Nov 2020 06:06:23 -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 2E2242240C; Fri, 20 Nov 2020 11:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1605870382; bh=+OEMdV7f+aW1tiV8eTWtyPfHVbglZl1WZyyVr6W4+CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xjqzmHQIHzOzqiq6pRyZUCni/5HKHJf3xFDLLzkXPyR283OyPrmfSjSnMBSMeozDW yXP/U+UeuPLXabl9uc9Al1l0C6EI7lDqeXQMApz+MyJjj0ZNhQ0gx2GdDtJQphF7+e M2UOMqB0Wc7ZMvTmR4TFr69WlJ8Fby8d/JtPHa0Y= 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 4.19 12/14] can: proc: can_remove_proc(): silence remove_proc_entry warning Date: Fri, 20 Nov 2020 12:03:33 +0100 Message-Id: <20201120104540.420581857@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201120104539.806156260@linuxfoundation.org> References: <20201120104539.806156260@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 @@ -467,6 +467,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); @@ -494,6 +497,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); }