]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mac80211: Free mpath object when rhashtable insertion fails
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 14 Feb 2019 14:03:25 +0000 (22:03 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837813
commit 4ff3a9d14c6c06eaa4e5976c61599ea2bd9e81b2 upstream.

When rhashtable insertion fails the mesh table code doesn't free
the now-orphan mesh path object.  This patch fixes that.

Cc: stable@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/mac80211/mesh_pathtbl.c

index 86c8dfef56a4c8f021b68aa723ced9447b5b9602..4fed1136adaf52f65031766f25168590204e6eee 100644 (file)
@@ -447,17 +447,15 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
 
        } while (unlikely(ret == -EEXIST && !mpath));
 
-       if (ret && ret != -EEXIST)
-               return ERR_PTR(ret);
-
-       /* At this point either new_mpath was added, or we found a
-        * matching entry already in the table; in the latter case
-        * free the unnecessary new entry.
-        */
-       if (ret == -EEXIST) {
+       if (ret) {
                kfree(new_mpath);
+
+               if (ret != -EEXIST)
+                       return ERR_PTR(ret);
+
                new_mpath = mpath;
        }
+
        sdata->u.mesh.mesh_paths_generation++;
        return new_mpath;
 }
@@ -487,6 +485,9 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,
                                            &new_mpath->rhash,
                                            mesh_rht_params);
 
+       if (ret)
+               kfree(new_mpath);
+
        sdata->u.mesh.mpp_paths_generation++;
        return ret;
 }