linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Jacopo Mondi" <jacopo+renesas@jmondi.org>,
	"Kieran Bingham" <kieran.bingham+renesas@ideasonboard.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Ramesh Shanmugasundaram" <rashanmu@gmail.com>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Steve Longerbeam" <slongerbeam@gmail.com>
Subject: [PATCH 2/5] media: rcar_drif: Fix fwnode reference leak when parsing DT
Date: Tue, 11 Aug 2020 23:59:36 +0300	[thread overview]
Message-ID: <20200811205939.19550-3-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <20200811205939.19550-1-laurent.pinchart+renesas@ideasonboard.com>

The fwnode reference corresponding to the endpoint is leaked in an error
path of the rcar_drif_parse_subdevs() function. Fix it, and reorganize
fwnode reference handling in the function to release references early,
simplifying error paths.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/rcar_drif.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c
index 3d2451ac347d..3f1e5cb8b197 100644
--- a/drivers/media/platform/rcar_drif.c
+++ b/drivers/media/platform/rcar_drif.c
@@ -1227,28 +1227,22 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr)
 	if (!ep)
 		return 0;
 
+	/* Get the endpoint properties */
+	rcar_drif_get_ep_properties(sdr, ep);
+
 	fwnode = fwnode_graph_get_remote_port_parent(ep);
+	fwnode_handle_put(ep);
 	if (!fwnode) {
 		dev_warn(sdr->dev, "bad remote port parent\n");
-		fwnode_handle_put(ep);
 		return -EINVAL;
 	}
 
 	sdr->ep.asd.match.fwnode = fwnode;
 	sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
 	ret = v4l2_async_notifier_add_subdev(notifier, &sdr->ep.asd);
-	if (ret) {
-		fwnode_handle_put(fwnode);
-		return ret;
-	}
-
-	/* Get the endpoint properties */
-	rcar_drif_get_ep_properties(sdr, ep);
-
 	fwnode_handle_put(fwnode);
-	fwnode_handle_put(ep);
 
-	return 0;
+	return ret;
 }
 
 /* Check if the given device is the primary bond */
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2020-08-11 21:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11 20:59 [PATCH 0/5] media: Fix asd dynamic allocation Laurent Pinchart
2020-08-11 20:59 ` [PATCH 1/5] media: v4l2-async: Document asd allocation requirements Laurent Pinchart
2020-09-08  5:08   ` Laurent Pinchart
2020-09-16 15:44   ` Kieran Bingham
2020-08-11 20:59 ` Laurent Pinchart [this message]
2020-09-16 15:46   ` [PATCH 2/5] media: rcar_drif: Fix fwnode reference leak when parsing DT Kieran Bingham
2020-08-11 20:59 ` [PATCH 3/5] media: rcar_drif: Allocate v4l2_async_subdev dynamically Laurent Pinchart
2020-09-16 15:53   ` Kieran Bingham
2020-08-11 20:59 ` [PATCH 4/5] media: rcar-csi2: " Laurent Pinchart
2020-08-11 21:43   ` Niklas Söderlund
2020-08-11 22:14     ` Laurent Pinchart
2020-08-11 20:59 ` [PATCH 5/5] media: i2c: max9286: " Laurent Pinchart
2020-09-08  5:08   ` Laurent Pinchart
2020-09-14 12:55   ` Jacopo Mondi
2020-08-31 19:44 ` [PATCH 0/5] media: Fix asd dynamic allocation Ramesh Shanmugasundaram
2020-09-01 10:46   ` Chris Paterson
2020-09-10 15:53     ` Fabrizio Castro

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=20200811205939.19550-3-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=rashanmu@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=slongerbeam@gmail.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).