diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2019-02-14 09:03:25 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2019-02-15 07:10:32 -0500 |
commit | 4ff3a9d14c6c06eaa4e5976c61599ea2bd9e81b2 (patch) | |
tree | 200760df5220490d556c827891bb4abfdcdf1aa0 | |
parent | b4c3fbe6360178dc2181b7b43b7ae793a192b282 (diff) |
mac80211: Free mpath object when rhashtable insertion fails
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>
-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, | |||
436 | } while (unlikely(ret == -EEXIST && !mpath)); | 436 | } while (unlikely(ret == -EEXIST && !mpath)); |
437 | spin_unlock_bh(&tbl->walk_lock); | 437 | spin_unlock_bh(&tbl->walk_lock); |
438 | 438 | ||
439 | if (ret && ret != -EEXIST) | 439 | if (ret) { |
440 | return ERR_PTR(ret); | ||
441 | |||
442 | /* At this point either new_mpath was added, or we found a | ||
443 | * matching entry already in the table; in the latter case | ||
444 | * free the unnecessary new entry. | ||
445 | */ | ||
446 | if (ret == -EEXIST) { | ||
447 | kfree(new_mpath); | 440 | kfree(new_mpath); |
441 | |||
442 | if (ret != -EEXIST) | ||
443 | return ERR_PTR(ret); | ||
444 | |||
448 | new_mpath = mpath; | 445 | new_mpath = mpath; |
449 | } | 446 | } |
447 | |||
450 | sdata->u.mesh.mesh_paths_generation++; | 448 | sdata->u.mesh.mesh_paths_generation++; |
451 | return new_mpath; | 449 | return new_mpath; |
452 | } | 450 | } |
@@ -481,6 +479,9 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata, | |||
481 | hlist_add_head_rcu(&new_mpath->walk_list, &tbl->walk_head); | 479 | hlist_add_head_rcu(&new_mpath->walk_list, &tbl->walk_head); |
482 | spin_unlock_bh(&tbl->walk_lock); | 480 | spin_unlock_bh(&tbl->walk_lock); |
483 | 481 | ||
482 | if (ret) | ||
483 | kfree(new_mpath); | ||
484 | |||
484 | sdata->u.mesh.mpp_paths_generation++; | 485 | sdata->u.mesh.mpp_paths_generation++; |
485 | return ret; | 486 | return ret; |
486 | } | 487 | } |