mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Aotian <chenaotian2@163.com>
To: miquel.raynal@bootlin.com
Cc: alex.aring@gmail.com, chenaotian2@163.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, linux-wpan@vger.kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com,
	stefan@datenfreihafen.org
Subject: Re: [PATCH] ieee802154: hwsim: Fix possible memory leaks
Date: Fri,  7 Apr 2023 17:48:20 +0800	[thread overview]
Message-ID: <20230407094820.45798-1-chenaotian2@163.com> (raw)
In-Reply-To: <20230407100148.16a0531e@xps-13>

> miquel.raynal@bootlin.com wrote on Date: Fri, 7 Apr 2023 10:01:48 +0200:
> > chenaotian2@163.com wrote on Fri,  7 Apr 2023 09:26:26 +0800:

> > After replacing e->info, it is necessary to free the old einfo.
> > 
> > Signed-off-by: Chen Aotian <chenaotian2@163.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;
> >  		}
> 
> I'm not an RCU expert but the fix LGTM.

> What about adding:

> Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb")
> Cc: stable@vger.kernelorg

Sure, I will resend this patch soon with adding those

Thanks,
Chen


  reply	other threads:[~2023-04-07  9:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-07  1:26 Chen Aotian
2023-04-07  8:01 ` Miquel Raynal
2023-04-07  9:48   ` Chen Aotian [this message]
2023-04-07  9:53 Chen Aotian
2023-04-07 13:46 ` Miquel Raynal
2023-04-07 22:20 ` Alexander Aring
2023-04-08  6:43   ` Chen Aotian

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=20230407094820.45798-1-chenaotian2@163.com \
    --to=chenaotian2@163.com \
    --cc=alex.aring@gmail.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=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

all inboxes | Powered by JetHome®