From 7e11d5027b1fed5bbd0d74842a0a60381a2be823 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 14 Sep 2017 14:34:39 +0200 Subject: media: tm6000: cleanup trival coding style issues - Delete seven error messages for a failed memory allocation - Adjust seven checks for null pointers - Use common error handling code in tm6000_usb_probe() - 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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/tm6000/tm6000-cards.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'drivers/media/usb/tm6000/tm6000-cards.c') diff --git a/drivers/media/usb/tm6000/tm6000-cards.c b/drivers/media/usb/tm6000/tm6000-cards.c index 2537643..7734754 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,22 +1194,21 @@ 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); if (nr >= TM6000_MAXBOARDS) { printk(KERN_ERR "tm6000: Supports only %i tm60xx boards.\n", TM6000_MAXBOARDS); - usb_put_dev(usbdev); - return -ENOMEM; + rc = -ENOMEM; + goto put_device; } /* Create and initialize dev struct */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) { - printk(KERN_ERR "tm6000" ": out of memory!\n"); - usb_put_dev(usbdev); - return -ENOMEM; + if (!dev) { + rc = -ENOMEM; + goto put_device; } spin_lock_init(&dev->slock); mutex_init(&dev->usb_lock); @@ -1313,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 */ @@ -1324,17 +1322,18 @@ 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); +put_device: usb_put_dev(usbdev); - - kfree(dev); return rc; } -- cgit v1.1