Skip to content

Commit b1c936e

Browse files
pchelkin91davem330
authored andcommitted
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: 4095e0e ("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>
1 parent 32d0a49 commit b1c936e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/net/vxlan/vxlan_vnifilter.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,12 @@ static struct vxlan_vni_node *vxlan_vni_alloc(struct vxlan_dev *vxlan,
713713
return vninode;
714714
}
715715

716+
static void vxlan_vni_free(struct vxlan_vni_node *vninode)
717+
{
718+
free_percpu(vninode->stats);
719+
kfree(vninode);
720+
}
721+
716722
static int vxlan_vni_add(struct vxlan_dev *vxlan,
717723
struct vxlan_vni_group *vg,
718724
u32 vni, union vxlan_addr *group,
@@ -740,7 +746,7 @@ static int vxlan_vni_add(struct vxlan_dev *vxlan,
740746
&vninode->vnode,
741747
vxlan_vni_rht_params);
742748
if (err) {
743-
kfree(vninode);
749+
vxlan_vni_free(vninode);
744750
return err;
745751
}
746752

@@ -763,8 +769,7 @@ static void vxlan_vni_node_rcu_free(struct rcu_head *rcu)
763769
struct vxlan_vni_node *v;
764770

765771
v = container_of(rcu, struct vxlan_vni_node, rcu);
766-
free_percpu(v->stats);
767-
kfree(v);
772+
vxlan_vni_free(v);
768773
}
769774

770775
static int vxlan_vni_del(struct vxlan_dev *vxlan,

0 commit comments

Comments
 (0)