[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230407154517.3752e1b7@xps-13>
Date: Fri, 7 Apr 2023 15:46:21 +0200
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Chen Aotian <chenaotian2@....com>
Cc: alex.aring@...il.com, stefan@...enfreihafen.org,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, linux-wpan@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ieee802154: hwsim: Fix possible memory leaks
Hi Chen,
(resending my answer since apparently the first time it failed)
chenaotian2@....com wrote on Fri, 7 Apr 2023 17:53:01 +0800:
> After replacing e->info, it is necessary to free the old einfo.
The title should contain:
- wpan (that's the tree you target, use --subject-prefix="PATCH wpan"
of git-format-patch)
- v2 (because that's a new version, use the -v2 option of
git-format-patch)
Apparently I mis-wrote the stable address, just add this line to the
commit:
Cc: stable@...r.kernel.org
(right now you sent it to stable@...r.kernelorg which is incorrect,
sorry for the typo)
> Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
And please carry the tags:
Reviewed-by: Miquel Raynal <miquel.raynal@...tlin.com>
> Signed-off-by: Chen Aotian <chenaotian2@....com>
> ---
> drivers/net/ieee802154/mac802154_hwsim.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
> index 8445c2189..6e7e10b17 100644
> --- a/drivers/net/ieee802154/mac802154_hwsim.c
> +++ b/drivers/net/ieee802154/mac802154_hwsim.c
> @@ -685,7 +685,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;
> @@ -723,8 +723,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;
> + einfo_old = rcu_dereference(e->info);
> rcu_assign_pointer(e->info, einfo);
> rcu_read_unlock();
> + kfree_rcu(einfo_old, rcu);
> mutex_unlock(&hwsim_phys_lock);
> return 0;
> }
Thanks,
Miquèl
Powered by blists - more mailing lists