Skip to content

Commit

Permalink
mac80211: Free mpath object when rhashtable insertion fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Herbert Xu authored and Johannes Berg committed Feb 15, 2019
1 parent b4c3fbe commit 4ff3a9d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions net/mac80211/mesh_pathtbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 4ff3a9d

Please sign in to comment.