mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-media@vger.kernel.org,
	"Andi Shyti" <andi.shyti@samsung.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Arvind Yadav" <arvind.yadav.cs@gmail.com>,
	"Bhumika Goyal" <bhumirks@gmail.com>,
	"Christophe Jaillet" <christophe.jaillet@wanadoo.fr>,
	"David Härdeman" <david@hardeman.nu>,
	"Hans Verkuil" <hans.verkuil@cisco.com>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Masahiro Yamada" <yamada.masahiro@socionext.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Santosh Kumar Singh" <kumar.san1093@gmail.com>,
	"Sean Young" <sean@mess.org>,
	"Wei Yongjun" <weiyongjun1@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 4/9] [media] tm6000: One function call less in tm6000_usb_probe() after error detection
Date: Fri, 15 Sep 2017 09:51:49 +0200	[thread overview]
Message-ID: <66140cb8-68e4-b891-2313-3c07e54ab3e2@users.sourceforge.net> (raw)
In-Reply-To: <2aade468-5dfd-76ee-f59f-c25864930f61@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Sep 2017 16:11:55 +0200

* Adjust jump targets so that the function "kfree" will be always called
  with a non-null pointer.

* Delete an initialisation for the local variable "dev"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/tm6000/tm6000-cards.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c
index e18632056976..77347541904d 100644
--- a/drivers/media/usb/tm6000/tm6000-cards.c
+++ b/drivers/media/usb/tm6000/tm6000-cards.c
@@ -1184,7 +1184,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
 			    const struct usb_device_id *id)
 {
 	struct usb_device *usbdev;
-	struct tm6000_core *dev = NULL;
+	struct tm6000_core *dev;
 	int i, rc = 0;
 	int nr = 0;
 	char *speed;
@@ -1194,7 +1194,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
 	/* Selects the proper interface */
 	rc = usb_set_interface(usbdev, 0, 1);
 	if (rc < 0)
-		goto err;
+		goto report_failure;
 
 	/* Check to see next free device and mark as used */
 	nr = find_first_zero_bit(&tm6000_devused, TM6000_MAXBOARDS);
@@ -1312,8 +1312,7 @@ static int tm6000_usb_probe(struct usb_interface *interface,
 	if (!dev->isoc_in.endp) {
 		printk(KERN_ERR "tm6000: probing error: no IN ISOC endpoint!\n");
 		rc = -ENODEV;
-
-		goto err;
+		goto free_device;
 	}
 
 	/* save our data pointer in this interface device */
@@ -1323,16 +1322,16 @@ static int tm6000_usb_probe(struct usb_interface *interface,
 
 	rc = tm6000_init_dev(dev);
 	if (rc < 0)
-		goto err;
+		goto free_device;
 
 	return 0;
 
-err:
+free_device:
+	kfree(dev);
+report_failure:
 	printk(KERN_ERR "tm6000: Error %d while registering\n", rc);
 
 	clear_bit(nr, &tm6000_devused);
-
-	kfree(dev);
 put_device:
 	usb_put_dev(usbdev);
 	return rc;
-- 
2.14.1

  parent reply	other threads:[~2017-09-15  7:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-15  7:46 [PATCH 0/9] [media] TM6000: Adjustments for some function implementations SF Markus Elfring
2017-09-15  7:48 ` [PATCH 1/9] [media] tm6000: Delete seven error messages for a failed memory allocation SF Markus Elfring
2017-09-15  7:49 ` [PATCH 2/9] [media] tm6000: Adjust seven checks for null pointers SF Markus Elfring
2017-09-15  7:50 ` [PATCH 3/9] [media] tm6000: Use common error handling code in tm6000_usb_probe() SF Markus Elfring
2017-09-15  7:51 ` SF Markus Elfring [this message]
2017-09-15  7:53 ` [PATCH 5/9] [media] tm6000: Delete an unnecessary variable initialisation " SF Markus Elfring
2017-09-15  7:56 ` [PATCH 6/9] [media] tm6000: Use common error handling code in tm6000_cards_setup() SF Markus Elfring
2017-09-15  7:57 ` [PATCH 7/9] [media] tm6000: Improve a size determination in dvb_init() SF Markus Elfring
2017-09-15  7:59 ` [PATCH 8/9] [media] tm6000: Use common error handling code in tm6000_start_stream() SF Markus Elfring
2017-09-15  8:00 ` [PATCH 9/9] [media] tm6000: Use common error handling code in tm6000_prepare_isoc() 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=66140cb8-68e4-b891-2313-3c07e54ab3e2@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=akpm@linux-foundation.org \
    --cc=andi.shyti@samsung.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=bhumirks@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=david@hardeman.nu \
    --cc=hans.verkuil@cisco.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kumar.san1093@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sean@mess.org \
    --cc=weiyongjun1@huawei.com \
    --cc=yamada.masahiro@socionext.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

all inboxes | Powered by JetHome®