Skip to content

Commit 4ff3a9d

Browse files
herbertxjmberg-intel
authored andcommitted
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>
1 parent b4c3fbe commit 4ff3a9d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

net/mac80211/mesh_pathtbl.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,15 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
436436
} while (unlikely(ret == -EEXIST && !mpath));
437437
spin_unlock_bh(&tbl->walk_lock);
438438

439-
if (ret && ret != -EEXIST)
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) {
439+
if (ret) {
447440
kfree(new_mpath);
441+
442+
if (ret != -EEXIST)
443+
return ERR_PTR(ret);
444+
448445
new_mpath = mpath;
449446
}
447+
450448
sdata->u.mesh.mesh_paths_generation++;
451449
return new_mpath;
452450
}
@@ -481,6 +479,9 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,
481479
hlist_add_head_rcu(&new_mpath->walk_list, &tbl->walk_head);
482480
spin_unlock_bh(&tbl->walk_lock);
483481

482+
if (ret)
483+
kfree(new_mpath);
484+
484485
sdata->u.mesh.mpp_paths_generation++;
485486
return ret;
486487
}

0 commit comments

Comments
 (0)