]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
vxlan: check return value of gro_cells_init()
authorTaehee Yoo <ap420073@gmail.com>
Wed, 18 Mar 2020 13:28:09 +0000 (13:28 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 3 Apr 2020 13:17:23 +0000 (15:17 +0200)
BugLink: https://bugs.launchpad.net/bugs/1870142
[ Upstream commit 384d91c267e621e0926062cfb3f20cb72dc16928 ]

gro_cells_init() returns error if memory allocation is failed.
But the vxlan module doesn't check the return value of gro_cells_init().

Fixes: 58ce31cca1ff ("vxlan: GRO support at tunnel layer")`
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
drivers/net/vxlan.c

index 592fc7f394535f909ec4283f5a757ebea0643c58..f5e5af92564da4e11765ee3771d0ec38caeb0108 100644 (file)
@@ -2963,10 +2963,19 @@ static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan,
 /* Setup stats when device is created */
 static int vxlan_init(struct net_device *dev)
 {
+       struct vxlan_dev *vxlan = netdev_priv(dev);
+       int err;
+
        dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
        if (!dev->tstats)
                return -ENOMEM;
 
+       err = gro_cells_init(&vxlan->gro_cells, dev);
+       if (err) {
+               free_percpu(dev->tstats);
+               return err;
+       }
+
        return 0;
 }
 
@@ -3227,8 +3236,6 @@ static void vxlan_setup(struct net_device *dev)
 
        vxlan->dev = dev;
 
-       gro_cells_init(&vxlan->gro_cells, dev);
-
        for (h = 0; h < FDB_HASH_SIZE; ++h) {
                spin_lock_init(&vxlan->hash_lock[h]);
                INIT_HLIST_HEAD(&vxlan->fdb_head[h]);