mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-10-31 16:54:21 +00:00
drivers: vxlan: vnifilter: free percpu vni stats on error path
In case rhashtable_lookup_insert_fast() fails inside vxlan_vni_add(), the
allocated percpu vni stats are not freed on the error path.
Introduce vxlan_vni_free() which would work as a nice wrapper to free
vxlan_vni_node resources properly.
Found by Linux Verification Center (linuxtesting.org).
Fixes: 4095e0e132 ("drivers: vxlan: vnifilter: per vni stats")
Suggested-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
32d0a49d36
commit
b1c936e9af
1 changed files with 8 additions and 3 deletions
|
|
@ -713,6 +713,12 @@ static struct vxlan_vni_node *vxlan_vni_alloc(struct vxlan_dev *vxlan,
|
||||||
return vninode;
|
return vninode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vxlan_vni_free(struct vxlan_vni_node *vninode)
|
||||||
|
{
|
||||||
|
free_percpu(vninode->stats);
|
||||||
|
kfree(vninode);
|
||||||
|
}
|
||||||
|
|
||||||
static int vxlan_vni_add(struct vxlan_dev *vxlan,
|
static int vxlan_vni_add(struct vxlan_dev *vxlan,
|
||||||
struct vxlan_vni_group *vg,
|
struct vxlan_vni_group *vg,
|
||||||
u32 vni, union vxlan_addr *group,
|
u32 vni, union vxlan_addr *group,
|
||||||
|
|
@ -740,7 +746,7 @@ static int vxlan_vni_add(struct vxlan_dev *vxlan,
|
||||||
&vninode->vnode,
|
&vninode->vnode,
|
||||||
vxlan_vni_rht_params);
|
vxlan_vni_rht_params);
|
||||||
if (err) {
|
if (err) {
|
||||||
kfree(vninode);
|
vxlan_vni_free(vninode);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -763,8 +769,7 @@ static void vxlan_vni_node_rcu_free(struct rcu_head *rcu)
|
||||||
struct vxlan_vni_node *v;
|
struct vxlan_vni_node *v;
|
||||||
|
|
||||||
v = container_of(rcu, struct vxlan_vni_node, rcu);
|
v = container_of(rcu, struct vxlan_vni_node, rcu);
|
||||||
free_percpu(v->stats);
|
vxlan_vni_free(v);
|
||||||
kfree(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vxlan_vni_del(struct vxlan_dev *vxlan,
|
static int vxlan_vni_del(struct vxlan_dev *vxlan,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue