[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211204231853.a4z2p3vv5jor4nxx@skbuf>
Date: Sat, 4 Dec 2021 23:18:54 +0000
From: Vladimir Oltean <vladimir.oltean@....com>
To: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: Florian Fainelli <f.fainelli@...il.com>,
Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Tobias Waldekranz <tobias@...dekranz.com>,
DENG Qingfang <dqfext@...il.com>,
Alvin Šipraga <alsi@...g-olufsen.dk>,
Kurt Kanzenbach <kurt@...utronix.de>,
Hauke Mehrtens <hauke@...ke-m.de>,
Woojung Huh <woojung.huh@...rochip.com>,
"UNGLinuxDriver@...rochip.com" <UNGLinuxDriver@...rochip.com>,
Sean Wang <sean.wang@...iatek.com>,
Landen Chao <Landen.Chao@...iatek.com>,
Matthias Brugger <matthias.bgg@...il.com>,
Claudiu Manoil <claudiu.manoil@....com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Linus Walleij <linus.walleij@...aro.org>,
George McCollister <george.mccollister@...il.com>
Subject: Re: [PATCH v2 net-next 5/7] net: dsa: keep the bridge_dev and
bridge_num as part of the same structure
On Sat, Dec 04, 2021 at 10:11:44PM +0200, Vladimir Oltean wrote:
> @@ -310,21 +306,31 @@ static int dsa_port_bridge_create(struct dsa_port *dp,
> struct netlink_ext_ack *extack)
> {
> struct dsa_switch *ds = dp->ds;
> - unsigned int bridge_num;
> + struct dsa_bridge *bridge;
>
> - dp->bridge_dev = br;
> -
> - if (!ds->max_num_bridges)
> + bridge = dsa_tree_bridge_find(ds->dst, br);
> + if (bridge) {
> + refcount_inc(&bridge->refcount);
> + dp->bridge = bridge;
> return 0;
> + }
> +
> + bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
> + if (!bridge)
> + return -ENOMEM;
> +
> + refcount_set(&bridge->refcount, 1);
> +
> + bridge->dev = br;
>
> - bridge_num = dsa_bridge_num_get(br, ds->max_num_bridges);
> - if (!bridge_num) {
> + bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges);
> + if (ds->max_num_bridges && !bridge->num) {
> NL_SET_ERR_MSG_MOD(extack,
> "Range of offloadable bridges exceeded");
There should be a kfree(bridge) here before returning -EOPNOTSUPP.
I'll wait for further feedback before reposting.
> return -EOPNOTSUPP;
> }
>
> - dp->bridge_num = bridge_num;
> + dp->bridge = bridge;
>
> return 0;
> }
Powered by blists - more mailing lists