public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kbuild test robot <lkp@intel.com>,
	dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org,
	Dan Carpenter <dan.carpenter@oracle.com>,
	David Airlie <airlied@linux.ie>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: kernel-janitors@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	kbuild-all@01.org, Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH v2 1/2] drm/rcar-du: Use common error handling code in rcar_du_encoders_init()
Date: Wed, 1 Nov 2017 16:39:54 +0100	[thread overview]
Message-ID: <56554dfd-6990-e104-ea70-e457f250fe5d@users.sourceforge.net> (raw)
In-Reply-To: <26b811dd-9dfa-cfd3-7d4d-e7f1c852b8ed@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 1 Nov 2017 15:57:31 +0100

* Add a jump target so that a bit of exception handling can be better
  reused at the end of this function.

* Increase the scope for the variable "ret".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
The declaration for the variable "ret" was moved out of a loop.

 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 566d1a948c8f..b6b341164aab 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -365,6 +365,7 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu)
 	struct device_node *np = rcdu->dev->of_node;
 	struct device_node *ep_node;
 	unsigned int num_encoders = 0;
+	int ret;
 
 	/*
 	 * Iterate over the endpoints and create one encoder for each output
@@ -374,13 +375,10 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu)
 		enum rcar_du_output output;
 		struct of_endpoint ep;
 		unsigned int i;
-		int ret;
 
 		ret = of_graph_parse_endpoint(ep_node, &ep);
-		if (ret < 0) {
-			of_node_put(ep_node);
-			return ret;
-		}
+		if (ret < 0)
+			goto put_node;
 
 		/* Find the output route corresponding to the port number. */
 		for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) {
@@ -401,10 +399,8 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu)
 		/* Process the output pipeline. */
 		ret = rcar_du_encoders_init_one(rcdu, output, &ep);
 		if (ret < 0) {
-			if (ret == -EPROBE_DEFER) {
-				of_node_put(ep_node);
-				return ret;
-			}
+			if (ret == -EPROBE_DEFER)
+				goto put_node;
 
 			continue;
 		}
@@ -413,6 +409,10 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu)
 	}
 
 	return num_encoders;
+
+put_node:
+	of_node_put(ep_node);
+	return ret;
 }
 
 static int rcar_du_properties_init(struct rcar_du_device *rcdu)
-- 
2.14.3

  reply	other threads:[~2017-11-01 15:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-24 16:00 [PATCH 0/2] R-Car Display Unit: Fine-tuning for some function implementations SF Markus Elfring
2017-10-24 16:01 ` [PATCH 1/2] drm/rcar-du: Use common error handling code in rcar_du_encoders_init() SF Markus Elfring
2017-10-25  6:01   ` Dan Carpenter
2017-10-25  6:35     ` Clarification for approaches around exception handling SF Markus Elfring
2017-10-26 12:40   ` [PATCH 1/2] drm/rcar-du: Use common error handling code in rcar_du_encoders_init() kbuild test robot
2017-11-01 15:38     ` [PATCH v2 0/2] R-Car Display Unit: Fine-tuning for some function implementations SF Markus Elfring
2017-11-01 15:39       ` SF Markus Elfring [this message]
2017-11-01 15:41       ` [PATCH v2 2/2] drm/rcar-du: Adjust 14 checks for null pointers SF Markus Elfring
2017-10-27 18:45   ` [PATCH 1/2] drm/rcar-du: Use common error handling code in rcar_du_encoders_init() Jani Nikula
2017-10-29 11:01     ` Geert Uytterhoeven
2017-10-29 17:12     ` Laurent Pinchart
2017-10-29 18:19       ` SF Markus Elfring
2017-10-30  9:52       ` [PATCH 1/2] " Jani Nikula
2017-10-30 10:03         ` SF Markus Elfring
2017-10-30 13:18         ` [PATCH 1/2] " Laurent Pinchart
2017-10-24 16:02 ` [PATCH 2/2] drm/rcar-du: Adjust 14 checks for null pointers SF Markus Elfring
2017-10-25  6:02   ` Dan Carpenter
2017-10-25  6:44     ` SF Markus Elfring
2017-10-25  7:32       ` Dan Carpenter
2017-10-25  7:39         ` Unicode characters in commit messages? SF Markus Elfring
2017-10-25  8:43           ` Dan Carpenter
2017-10-25  9:16             ` SF Markus Elfring

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=56554dfd-6990-e104-ea70-e457f250fe5d@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=airlied@linux.ie \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert@linux-m68k.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=kbuild-all@01.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lkp@intel.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