From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-media@vger.kernel.org,
Arvind Yadav <arvind.yadav.cs@gmail.com>,
Hans Verkuil <hans.verkuil@cisco.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Shyam Saini <mayhs11saini@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/4] [media] cpia2: Use common error handling code in cpia2_usb_probe()
Date: Sun, 17 Sep 2017 15:31:31 +0200 [thread overview]
Message-ID: <a5c38437-f79b-e92e-b571-dd240090ca2b@users.sourceforge.net> (raw)
In-Reply-To: <c2ff478e-94d7-6c92-f467-69f5b66b8a1e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 17 Sep 2017 12:40:14 +0200
Add a jump target 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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/cpia2/cpia2_usb.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 6089036049d9..c6be2786a66f 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -849,13 +849,11 @@ static int cpia2_usb_probe(struct usb_interface *intf,
if (ret < 0) {
ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto free_data;
}
if((ret = cpia2_init_camera(cam)) < 0) {
ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto free_data;
}
LOG(" CPiA Version: %d.%02d (%d.%d)\n",
@@ -877,9 +875,12 @@ static int cpia2_usb_probe(struct usb_interface *intf,
if (ret < 0) {
ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto free_data;
}
return 0;
+
+free_data:
+ kfree(cam);
+ return ret;
}
--
2.14.1
next prev parent reply other threads:[~2017-09-17 13:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 13:30 [PATCH 0/4] [media] CPia2: Fine-tuning for four function implementations SF Markus Elfring
2017-09-17 13:31 ` SF Markus Elfring [this message]
2017-09-17 13:32 ` [PATCH 2/4] [media] cpia2: Adjust two function calls together with a variable assignment SF Markus Elfring
2017-09-17 13:34 ` [PATCH 3/4] [media] cpia2: Delete unnecessary null pointer checks in free_sbufs() SF Markus Elfring
2017-09-17 13:35 ` [PATCH 4/4] [media] cpia2: Delete an unnecessary return statement in process_frame() 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=a5c38437-f79b-e92e-b571-dd240090ca2b@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=arvind.yadav.cs@gmail.com \
--cc=hans.verkuil@cisco.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mayhs11saini@gmail.com \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.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
Powered by JetHome