diff options
author | Herbert Xu | 2019-02-14 15:03:25 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2019-02-27 10:08:49 +0100 |
commit | a35b18616a7351674921fc78080ad931e368c8fb (patch) | |
tree | ddeba0535afef716e5b5681ab02b22dee9d8d2a3 /net/mac80211 | |
parent | mac80211: Use linked list instead of rhashtable walk for mesh tables (diff) | |
download | kernel-qcow2-linux-a35b18616a7351674921fc78080ad931e368c8fb.tar.gz kernel-qcow2-linux-a35b18616a7351674921fc78080ad931e368c8fb.tar.xz kernel-qcow2-linux-a35b18616a7351674921fc78080ad931e368c8fb.zip |
mac80211: Free mpath object when rhashtable insertion fails
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>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/mesh_pathtbl.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 884a0d212e8b..c3a7396fb955 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -436,17 +436,15 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, } while (unlikely(ret == -EEXIST && !mpath)); spin_unlock_bh(&tbl->walk_lock); - 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; } @@ -481,6 +479,9 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata, hlist_add_head_rcu(&new_mpath->walk_list, &tbl->walk_head); spin_unlock_bh(&tbl->walk_lock); + if (ret) + kfree(new_mpath); + sdata->u.mesh.mpp_paths_generation++; return ret; } |