Linux Media Controller development
 help / color / mirror / Atom feed
From: Philipp Zabel <pza@pengutronix.de>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Philipp Zabel <p.zabel@pengutronix.de>,
	Grant Likely <grant.likely@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	devel@driverdev.osuosl.org,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Russell King <rmk+kernel@arm.linux.org.uk>,
	kernel@pengutronix.de
Subject: Re: [PATCH v5 1/6] of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint
Date: Sun, 9 Nov 2014 16:36:44 +0100	[thread overview]
Message-ID: <20141109153644.GA3132@pengutronix.de> (raw)
In-Reply-To: <Pine.LNX.4.64.1411072255130.4252@axis700.grange>

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.

regards
Philipp

  reply	other threads:[~2014-11-09 15:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-29 18:03 [PATCH v5 0/6] Add of-graph helpers to loop over endpoints and find ports by id Philipp Zabel
2014-09-29 18:03 ` [PATCH v5 1/6] of: Decrement refcount of previous endpoint in of_graph_get_next_endpoint Philipp Zabel
2014-09-29 22:10   ` Greg Kroah-Hartman
2014-09-30  8:06     ` Philipp Zabel
2014-11-03 10:02       ` Philipp Zabel
2014-11-03 10:19   ` Mauro Carvalho Chehab
2014-11-07 22:06   ` Guennadi Liakhovetski
2014-11-09 15:36     ` Philipp Zabel [this message]
2014-11-09 15:51       ` Guennadi Liakhovetski
2014-12-01 12:35         ` Philipp Zabel
2014-09-29 18:03 ` [PATCH v5 2/6] of: Add for_each_endpoint_of_node helper macro Philipp Zabel
2014-09-29 18:03 ` [PATCH v5 3/6] of: Add of_graph_get_port_by_id function Philipp Zabel
2014-09-29 18:03 ` [PATCH v5 4/6] drm: use for_each_endpoint_of_node macro in drm_of_find_possible_crtcs Philipp Zabel
2014-09-29 18:03 ` [PATCH v5 5/6] imx-drm: use for_each_endpoint_of_node macro in imx_drm_encoder_get_mux_id Philipp Zabel
2014-09-29 18:03 ` [PATCH v5 6/6] imx-drm: use for_each_endpoint_of_node macro in imx_drm_encoder_parse_of Philipp Zabel

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=20141109153644.GA3132@pengutronix.de \
    --to=pza@pengutronix.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=p.zabel@pengutronix.de \
    --cc=rmk+kernel@arm.linux.org.uk \
    /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