Commit 9574fb55 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: bridge: reduce indentation level in fdb_create

We can express the same logic without an "if" condition as big as the
function, just return early if the kmem_cache_alloc() call fails.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Acked-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f6814fdc
...@@ -382,23 +382,26 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br, ...@@ -382,23 +382,26 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
unsigned long flags) unsigned long flags)
{ {
struct net_bridge_fdb_entry *fdb; struct net_bridge_fdb_entry *fdb;
int err;
fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC); fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);
if (fdb) { if (!fdb)
memcpy(fdb->key.addr.addr, addr, ETH_ALEN); return NULL;
WRITE_ONCE(fdb->dst, source);
fdb->key.vlan_id = vid; memcpy(fdb->key.addr.addr, addr, ETH_ALEN);
fdb->flags = flags; WRITE_ONCE(fdb->dst, source);
fdb->updated = fdb->used = jiffies; fdb->key.vlan_id = vid;
if (rhashtable_lookup_insert_fast(&br->fdb_hash_tbl, fdb->flags = flags;
&fdb->rhnode, fdb->updated = fdb->used = jiffies;
br_fdb_rht_params)) { err = rhashtable_lookup_insert_fast(&br->fdb_hash_tbl, &fdb->rhnode,
kmem_cache_free(br_fdb_cache, fdb); br_fdb_rht_params);
fdb = NULL; if (err) {
} else { kmem_cache_free(br_fdb_cache, fdb);
hlist_add_head_rcu(&fdb->fdb_node, &br->fdb_list); return NULL;
}
} }
hlist_add_head_rcu(&fdb->fdb_node, &br->fdb_list);
return fdb; return fdb;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment