Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp442039pxu; Fri, 11 Dec 2020 06:09:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwd1X4skobBlGJOEyV7EIbuoJH7X50tV4+Sn8hRxyeFJLBEEVVQ2trfjj75mfYrz+i7Rzqe X-Received: by 2002:a50:ccdb:: with SMTP id b27mr12301574edj.20.1607695775597; Fri, 11 Dec 2020 06:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607695775; cv=none; d=google.com; s=arc-20160816; b=DSoFatyi48iGYeEXxN5JyUnuj0sM8JR3tBvli3NSd02cWlkAjmmPa9ctnRYlvTt44X WMmQP886qRn0L2frXJX9fLeEgo6oecc5n3sC41Uyu83WGvswAXff12w1NLbDLdsyNkHj WkQVDgHU8H7cbZO/4xZ16eQaMC7wmjb9GNlsHBNq8u7fCt9FgqBG2o/1Ckpo+Fj12YXC kiaNpmaV5DBCT2rNBSOBDRdklnbMaAOXy6BzxXVk/6dNkURg+K3CzAWJMwD32CpvR5Od a8zo8sla2zpws8yuLOwo0uFuzu3cFSS7dVHVEdUkSvyU7GLRz0dIqY0ciRhJZPaCe2sL bQzw== 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=h8deO5F+jtnJULjmZvcLMJv/lP/a7x2sHn2kd5iVU8s=; b=Fy1Wz8q9CQ39oS/9gDcCSC07syC/ZO0AGGQkccO6tfXjelWfhg35HfjRyR0lwRhpnL viPp7pLj6daxjI4Fxlw3CUiQlp4KXAH6MrotinUMaxoSxmWSwd6q84NFWOODs8pvfi2w gi/wCQJ1VUkBza2D3XRl0FJ4RJBLNgRQUtQ1QehjDdf63/OAdFCcQhUc2W0i9GByIe1m cOZm5SOn2Bbxe4OgeOMyap53Vbus2KYBBwLWmrkh76UUYweHy+jlF+V+Qqc6cy10FrZs HFIYQD+wHdBaLH7AK4kOowJwjcD8gEbYIGPaCFTjUovTEbGZKDAzj9Ud65OCkgfmtecX gOiw== 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 s7si4707841edx.227.2020.12.11.06.09.12; Fri, 11 Dec 2020 06:09:35 -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 S2405505AbgLKMZL (ORCPT + 99 others); Fri, 11 Dec 2020 07:25:11 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9169 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391658AbgLKMYl (ORCPT ); Fri, 11 Dec 2020 07:24:41 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Csqgv0w1fz15ZR7; Fri, 11 Dec 2020 20:23:23 +0800 (CST) Received: from huawei.com (10.175.113.133) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Fri, 11 Dec 2020 20:23:52 +0800 From: Wang Hai To: , , , CC: , , Subject: [PATCH v2] net: bridge: Fix a warning when del bridge sysfs Date: Fri, 11 Dec 2020 20:29:21 +0800 Message-ID: <20201211122921.40386-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 I got a warining report: 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 In br_device_event(), if the bridge sysfs fails to be added, br_device_event() should return error. This can prevent warining when removing bridge sysfs that do not exist. Fixes: bb900b27a2f4 ("bridge: allow creating bridge devices with netlink") Reported-by: Hulk Robot Signed-off-by: Wang Hai --- v1->v2: Fix this by check br_sysfs_addbr() return value as Nik's suggestion net/bridge/br.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/bridge/br.c b/net/bridge/br.c index 401eeb9142eb..1b169f8e7491 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -43,7 +43,10 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v if (event == NETDEV_REGISTER) { /* register of bridge completed, add sysfs entries */ - br_sysfs_addbr(dev); + err = br_sysfs_addbr(dev); + if (err) + return notifier_from_errno(err); + return NOTIFY_DONE; } } -- 2.17.1