linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	"Sergei Shtylyov (sergei.shtylyov@cogentembedded.com)" 
	<sergei.shtylyov@cogentembedded.com>
Subject: RE: question about drivers/phy/renesas/phy-rcar-gen2.c
Date: Wed, 27 Feb 2019 01:06:25 +0000	[thread overview]
Message-ID: <TY2PR01MB481259F0AFBF6DEF9565792CD8740@TY2PR01MB4812.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1902261000420.3499@hadrien>

Hello,

> From: Julia Lawall, Sent: Tuesday, February 26, 2019 6:01 PM
> 
> On Tue, 26 Feb 2019, Yoshihiro Shimoda wrote:
> 
> > Hello,
> > (Sergei made this code, so I added his email as CC)
> >
> > I'm sorry for the delayed response.
> >
> > > From: Julia Lawall, Sent: Sunday, February 3, 2019 4:03 PM
> > >
> > > Hello,
> > >
> > > I was wondering whether phy-rcar-gen2.c would use dynamically allocated
> > > device nodes?
> >
> > I'm sorry, but what is "dynamically allocated device nodes"?
> 
> Device nodes for which there will be a meor leak if one doesn't put
> of_node_put.

Thank you. I understood it.

> julia
> 
> >
> > Best regards,
> > Yoshihiro Shimoda
> >
> > >  If so, it looks like the following code could cause a
> > > use-after-free, due to not incrementing th reference count:
> > >
> > > 	for_each_child_of_node(dev->of_node, np) {
> > > 		struct rcar_gen2_channel *channel = drv->channels + i;
> > > 		u32 channel_num;
> > > 		int error, n;
> > >
> > > 		channel->of_node = np;

IIUC, since the channel->of_node will be used for comparing the pointer
in rcar_gen2_phy_xlate(), it is not use-after-free.
However, the for_each_child_of_node() in rcar_gen2_phy_probe() will return
without of_put_node() at error paths. So, I'll submit a bugfix patch later.

Thank you very much for your report!

Best regards,
Yoshihiro Shimoda

> > > 		...
> > > 	}
> > >
> > > On the other hand, if the reference cound it incrememnted, preventing
> > > memory leaks in the case where the probe function fails would entail some
> > > complex rewriting of the code, so I thought it would be better to ask
> > > first.
> > >
> > > thanks,
> > > julia
> >

  reply	other threads:[~2019-02-27  1:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-03  7:02 question about drivers/phy/renesas/phy-rcar-gen2.c Julia Lawall
2019-02-26  8:54 ` Yoshihiro Shimoda
2019-02-26  9:01   ` Julia Lawall
2019-02-27  1:06     ` Yoshihiro Shimoda [this message]
2019-02-27  6:08       ` Julia Lawall

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=TY2PR01MB481259F0AFBF6DEF9565792CD8740@TY2PR01MB4812.jpnprd01.prod.outlook.com \
    --to=yoshihiro.shimoda.uh@renesas.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /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 NNTP newsgroup(s).