lkml.org 
[lkml]   [2014]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 1/6] of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint
On Sun, 9 Nov 2014, Philipp Zabel wrote:

> Hi Guennadi,
>
> On Fri, Nov 07, 2014 at 11:06:21PM +0100, Guennadi Liakhovetski wrote:
> > Hi Philipp,
> >
> > Thanks for the patch and sorry for a late reply. I did look at your
> > patches earlier too, but maybe not attentively enough, or maybe I'm
> > misunderstanding something now. In the scan_of_host() function in
> > soc_camera.c as of current -next I see:
> >
> > epn = of_graph_get_next_endpoint(np, epn);
> >
> > which already looks like a refcount leak to me. If epn != NULL, its
> > refcount is incremented, but then immediately the variable gets
> > overwritten, and there's no extra copy of that variable to fix this. If
> > I'm right, then that bug in itself should be fixed, ideally before your
> > patch is applied. But in fact, your patch fixes this, since it modifies
> > of_graph_get_next_endpoint() to return with prev's refcount not
> > incremented, right? Whereas the of_node_put(epn) later down in
> > scan_of_host() decrements refcount of the _next_ endpoint, not the
> > previous one, so, it should be left alone? I.e. AFAICT your modification
> > to of_graph_get_next_endpoint() fixes soc_camera.c with no further
> > modifications to it required?
>
> You are right. With the old implementation, you'd have to do the
> epn = of_graph_get_next_endpoint(np, prev); of_node_put(prev); prev = epn;
> dance to avoid leaking a reference to the first endpoint. This series
> accidentally fixes soc_camera by changing of_graph_get_next_endpoint
> to decrement the reference count itself.

Right, so, the patch has to be adjusted not to touch soc_camera.c at all.

Thanks
Guennadi

>
> regards
> Philipp
>


\
 
 \ /
  Last update: 2014-11-09 17:21    [W:0.059 / U:2.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site