mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 14:24:11 +08:00
ieee802154: hwsim: Fix possible memory leaks
[ Upstream commita616752947
] After replacing e->info, it is necessary to free the old einfo. Fixes:f25da51fdc
("ieee802154: hwsim: add replacement for fakelb") Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: Chen Aotian <chenaotian2@163.com> Link: https://lore.kernel.org/r/20230409022048.61223-1-chenaotian2@163.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
deb5c34ee4
commit
84de63b26d
@ -540,7 +540,7 @@ static int hwsim_del_edge_nl(struct sk_buff *msg, struct genl_info *info)
|
||||
static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info)
|
||||
{
|
||||
struct nlattr *edge_attrs[MAC802154_HWSIM_EDGE_ATTR_MAX + 1];
|
||||
struct hwsim_edge_info *einfo;
|
||||
struct hwsim_edge_info *einfo, *einfo_old;
|
||||
struct hwsim_phy *phy_v0;
|
||||
struct hwsim_edge *e;
|
||||
u32 v0, v1;
|
||||
@ -580,8 +580,10 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info)
|
||||
list_for_each_entry_rcu(e, &phy_v0->edges, list) {
|
||||
if (e->endpoint->idx == v1) {
|
||||
einfo->lqi = lqi;
|
||||
rcu_assign_pointer(e->info, einfo);
|
||||
einfo_old = rcu_replace_pointer(e->info, einfo,
|
||||
lockdep_is_held(&hwsim_phys_lock));
|
||||
rcu_read_unlock();
|
||||
kfree_rcu(einfo_old, rcu);
|
||||
mutex_unlock(&hwsim_phys_lock);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user