From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-media@vger.kernel.org,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 3/4] [media] omap3isp: Use common error handling code in isp_video_open()
Date: Sun, 24 Sep 2017 20:07:31 +0200 [thread overview]
Message-ID: <a3bcee14-f5d2-8648-a925-3dfd393e8f55@users.sourceforge.net> (raw)
In-Reply-To: <692bab24-7990-c971-b577-b2dea4176e64@users.sourceforge.net>
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
next prev parent reply other threads:[~2017-09-24 18:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-24 18:03 [PATCH 0/4] [media] OMAP3 ISP: Adjustments for some function implementations SF Markus Elfring
2017-09-24 18:04 ` [PATCH 1/4] [media] omap3isp: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-09-24 18:06 ` [PATCH 2/4] [media] omap3isp: Adjust 53 checks for null pointers SF Markus Elfring
2017-09-24 18:07 ` SF Markus Elfring [this message]
2017-09-24 18:08 ` [PATCH 4/4] [media] omap3isp: Delete an unnecessary variable initialisation in isp_video_open() 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=a3bcee14-f5d2-8648-a925-3dfd393e8f55@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
/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
Powered by JetHome