Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1738243

[PATCH 3/4] [media] omap3isp: Use common error handling code in isp_video_open()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 3/4] [media] omap3isp: Use common error handling code in isp_video_open()
Date 2017-09-24 20:10 +0200
Message-ID <utjvQ-3xk-5@gated-at.bofh.it> (permalink)
References <utjvQ-3xk-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 24 Sep 2017 19:30:52 +0200

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

  This issue was detected by using the Coccinelle software.

* Delete a repeated check (for the variable "ret") which became unnecessary
  with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/platform/omap3isp/ispvideo.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index 7b9bd684337a..d4118466fc8a 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -1315,14 +1315,12 @@ static int isp_video_open(struct file *file)
 	/* If this is the first user, initialise the pipeline. */
 	if (omap3isp_get(video->isp) == NULL) {
 		ret = -EBUSY;
-		goto done;
+		goto delete_fh;
 	}
 
 	ret = v4l2_pipeline_pm_use(&video->video.entity, 1);
-	if (ret < 0) {
-		omap3isp_put(video->isp);
-		goto done;
-	}
+	if (ret < 0)
+		goto put_isp;
 
 	queue = &handle->queue;
 	queue->type = video->type;
@@ -1335,10 +1333,8 @@ static int isp_video_open(struct file *file)
 	queue->dev = video->isp->dev;
 
 	ret = vb2_queue_init(&handle->queue);
-	if (ret < 0) {
-		omap3isp_put(video->isp);
-		goto done;
-	}
+	if (ret < 0)
+		goto put_isp;
 
 	memset(&handle->format, 0, sizeof(handle->format));
 	handle->format.type = video->type;
@@ -1346,14 +1342,15 @@ static int isp_video_open(struct file *file)
 
 	handle->video = video;
 	file->private_data = &handle->vfh;
+	goto exit;
 
-done:
-	if (ret < 0) {
-		v4l2_fh_del(&handle->vfh);
-		v4l2_fh_exit(&handle->vfh);
-		kfree(handle);
-	}
-
+put_isp:
+	omap3isp_put(video->isp);
+delete_fh:
+	v4l2_fh_del(&handle->vfh);
+	v4l2_fh_exit(&handle->vfh);
+	kfree(handle);
+exit:
 	return ret;
 }
 
-- 
2.14.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] [media] OMAP3 ISP: Adjustments for some function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-24 20:10 +0200
  [PATCH 3/4] [media] omap3isp: Use common error handling code in  isp_video_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-24 20:10 +0200
  [PATCH 4/4] [media] omap3isp: Delete an unnecessary variable  initialisation in isp_video_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-24 20:10 +0200
  [PATCH 2/4] [media] omap3isp: Adjust 53 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-24 20:10 +0200
  [PATCH 1/4] [media] omap3isp: Delete an error message for a failed  memory allocation in three functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-24 20:10 +0200

csiph-web