From: Alexander Aring <aahringo@redhat.com>
To: Chen Aotian <chenaotian2@163.com>
Cc: alex.aring@gmail.com, stefan@datenfreihafen.org,
miquel.raynal@bootlin.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
linux-wpan@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATH wpan v2] ieee802154: hwsim: Fix possible memory leaks
Date: Sat, 8 Apr 2023 11:04:58 -0400 [thread overview]
Message-ID: <CAK-6q+j4aDoA2KG3Qzxg2XMu6nPxUuExuBw=sQ3+VqJuB5cj0A@mail.gmail.com> (raw)
In-Reply-To: <20230408081934.54002-1-chenaotian2@163.com>
Hi,
On Sat, Apr 8, 2023 at 4:22 AM Chen Aotian <chenaotian2@163.com> wrote:
>
> After replacing e->info, it is necessary to free the old einfo.
>
> Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Chen Aotian <chenaotian2@163.com>
> ---
>
> V1 -> V2:
> * Using rcu_replace_pointer() is better then rcu_dereference()
> and rcu_assign_pointer().
>
> drivers/net/ieee802154/mac802154_hwsim.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
> index 8445c2189..6ffcadb9d 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;
> - rcu_assign_pointer(e->info, einfo);
> + einfo_old = rcu_replace_pointer(e->info, einfo,
> + lock_is_held(&hwsim_phys_lock));
I think lockdep_is_held() should be correct here.
- Alex
prev parent reply other threads:[~2023-04-08 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-08 8:19 [PATH wpan v2] ieee802154: hwsim: Fix possible memory leaks Chen Aotian
2023-04-08 9:57 ` kernel test robot
2023-04-08 15:04 ` Alexander Aring [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK-6q+j4aDoA2KG3Qzxg2XMu6nPxUuExuBw=sQ3+VqJuB5cj0A@mail.gmail.com' \
--to=aahringo@redhat.com \
--cc=alex.aring@gmail.com \
--cc=chenaotian2@163.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=stefan@datenfreihafen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).