Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp50106pxu; Tue, 1 Dec 2020 06:00:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkmvXaP+rsZmguxcBTxMUO7jgpMV534Vt/SNedyJaS0y1lz3kJ8hRdlGd14Uz0kPADdi+a X-Received: by 2002:a50:9f4a:: with SMTP id b68mr1087740edf.296.1606831220908; Tue, 01 Dec 2020 06:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606831220; cv=none; d=google.com; s=arc-20160816; b=fS6h5KFf+YTpuDH+8v6kyi8WhJNXe6jaqv6sty+xhpRjdmgYSwUZVaDrreaTVJ/tch P3ziXCIX2/EvfBnc4eG+HOslUf7Zj3jBzfxLAYAcV/TT7sv3RuIz8OP6Cw1lf8XHJQei mbzwoYQ4fcU+2t/6VkMvwMm5/K+g+4JjGyBYnWDy9PUsVrxLi4e/qKG5+VSOXK1IQOl9 ShfyyPw7DdWJ5JrRI11U6YgqxcyIk/7dZupFYIJRv/ftOknS/osSfFbb3nPC2UEMuQyu h9MPt0sHE4CMErjpWvCCGQC/smh1r+sC2smGV61Oa4D4vmy0uOKleOh330q9qVwYG36Z bOmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=GqTjTLnpRgwRuIZD9QSeDo839wV6Inzr5QLG6m7ORkE=; b=EoQyKFTxgVom0IlO5dPhWGSTr9lxkonoJga0mPdXlf+NOEhQruPUZhBbGYDdwtUQ5J 1Sscz9ucmwy0v4xff9MXsAkv/wvqbxQJ9ssHVRCf/96kDbFn1fUoUPMUgknPzwUJPVEf Dq8GPLSwKedDMttajYojIxfv6Uc4fHA4SAQhwViWAWLQmG2Wj5rJO3EKc3B3ynQTcZ8Y haNFakn9Sijzz/f7q5h6RmBP+7cRKpqme4W+aVfFed6Cajb4rZhQCcNpcOlJCRgAMQAS hjwG9KZb77TKaK1o75ui57TRsHfkZe7QcWSP4zgzeT0QQNkmSYyP/ObrmOFo3DqVKAiO 4CZg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si992450ejh.106.2020.12.01.05.59.56; Tue, 01 Dec 2020 06:00:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391465AbgLAN4T (ORCPT + 99 others); Tue, 1 Dec 2020 08:56:19 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:8487 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388215AbgLAN4S (ORCPT ); Tue, 1 Dec 2020 08:56:18 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4ClkBX1XnPzhlLV; Tue, 1 Dec 2020 21:55:16 +0800 (CST) Received: from huawei.com (10.175.113.133) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Tue, 1 Dec 2020 21:55:31 +0800 From: Wang Hai To: , , , CC: , , Subject: [PATCH net] net: bridge: Fix a warning when del bridge sysfs Date: Tue, 1 Dec 2020 22:01:14 +0800 Message-ID: <20201201140114.67455-1-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.133] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If adding bridge sysfs fails, br->ifobj will be NULL, there is no need to delete its non-existent sysfs when deleting the bridge device, otherwise, it will cause a warning. So, when br->ifobj == NULL, directly return can fix this bug. br_sysfs_addbr: can't create group bridge4/bridge ------------[ cut here ]------------ sysfs group 'bridge' not found for kobject 'bridge4' WARNING: CPU: 2 PID: 9004 at fs/sysfs/group.c:279 sysfs_remove_group fs/sysfs/group.c:279 [inline] WARNING: CPU: 2 PID: 9004 at fs/sysfs/group.c:279 sysfs_remove_group+0x153/0x1b0 fs/sysfs/group.c:270 Modules linked in: iptable_nat ... Call Trace: br_dev_delete+0x112/0x190 net/bridge/br_if.c:384 br_dev_newlink net/bridge/br_netlink.c:1381 [inline] br_dev_newlink+0xdb/0x100 net/bridge/br_netlink.c:1362 __rtnl_newlink+0xe11/0x13f0 net/core/rtnetlink.c:3441 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3500 rtnetlink_rcv_msg+0x385/0x980 net/core/rtnetlink.c:5562 netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2494 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1330 netlink_sendmsg+0x793/0xc80 net/netlink/af_netlink.c:1919 sock_sendmsg_nosec net/socket.c:651 [inline] sock_sendmsg+0x139/0x170 net/socket.c:671 ____sys_sendmsg+0x658/0x7d0 net/socket.c:2353 ___sys_sendmsg+0xf8/0x170 net/socket.c:2407 __sys_sendmsg+0xd3/0x190 net/socket.c:2440 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Reported-by: Hulk Robot Signed-off-by: Wang Hai --- net/bridge/br_sysfs_br.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index 7db06e3f642a..1e9cbf31d904 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c @@ -991,6 +991,9 @@ void br_sysfs_delbr(struct net_device *dev) struct kobject *kobj = &dev->dev.kobj; struct net_bridge *br = netdev_priv(dev); + if (!br->ifobj) + return; + kobject_put(br->ifobj); sysfs_remove_bin_file(kobj, &bridge_forward); sysfs_remove_group(kobj, &bridge_group); -- 2.17.1