From patchwork Sat Sep 12 14:49:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ellingsworth X-Patchwork-Id: 47074 X-Patchwork-Delegate: dougsland@redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8CEnXuO027528 for ; Sat, 12 Sep 2009 14:49:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754592AbZILOt3 (ORCPT ); Sat, 12 Sep 2009 10:49:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754556AbZILOt3 (ORCPT ); Sat, 12 Sep 2009 10:49:29 -0400 Received: from mail-qy0-f172.google.com ([209.85.221.172]:50386 "EHLO mail-qy0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754520AbZILOt2 (ORCPT ); Sat, 12 Sep 2009 10:49:28 -0400 Received: by mail-qy0-f172.google.com with SMTP id 2so1629968qyk.21 for ; Sat, 12 Sep 2009 07:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :reply-to:user-agent:mime-version:to:subject:content-type; bh=3XFPmkDToNca7RjuQzBlA5ABpQX4WjgA3+GGvH/QfXg=; b=FjL7XO+nzxLOPsapJ8zE26T1FxQlIsjVJl2zTZ4CN5H8WGzVu0my98l4X2T7LqaMFa t1CQPC/qk1p0FSQU3mJyPBGOcy9MabGL6slbSJvcf9H4QOM+z7+lN7JkHVZtJWSH9AA2 bidzRATlbb3a4s0JoOJ9LnCRSioLw3UyOnkKc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:content-type; b=Xrscs7zFRMsxMLC3cGE7xVRNg6fKJR4D9I56FjbZhcv3F87m8oA3hq6RWfZWSzMvlA AJFcwKKZyPzQdmvutXCWWYP+GvJAGJkVkMLHje/4CJ6nZ9gMyGUrcSOQbou0yk/LYYqP GXLWw+XrwOR2/LkCqM6V13zNMN6Ooq0y3a/90= Received: by 10.224.91.143 with SMTP id n15mr3768211qam.71.1252766967044; Sat, 12 Sep 2009 07:49:27 -0700 (PDT) Received: from ?192.168.10.110? (cpe-71-72-62-249.neo.res.rr.com [71.72.62.249]) by mx.google.com with ESMTPS id 2sm2158233qwi.26.2009.09.12.07.49.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 12 Sep 2009 07:49:20 -0700 (PDT) Message-ID: <4AABB4E8.7030507@gmail.com> Date: Sat, 12 Sep 2009 10:49:12 -0400 From: David Ellingsworth Reply-To: david@identd.dyndns.org User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: linux-media@vger.kernel.org, klimov.linux@gmail.com Subject: [RFC/RFT 03/10] radio-mr800: simplify error paths in usb probe callback Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From 0cdbd79a6e87a8a2862a6c1309c8fdf83c80ba61 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 00:13:16 -0400 Subject: [PATCH 03/10] mr800: simplify error paths in usb probe callback Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-) strlcpy(radio->videodev.name, v4l2_dev->name, @@ -736,14 +735,20 @@ static int usb_amradio_probe(struct usb_interface *intf, radio_nr); if (retval < 0) { dev_err(&intf->dev, "could not register video device\n"); - v4l2_device_unregister(v4l2_dev); - kfree(radio->buffer); - kfree(radio); - return -EIO; + goto err_vdev; } usb_set_intfdata(intf, radio); return 0; + +err_vdev: + v4l2_device_unregister(v4l2_dev); +err_v4l2: + kfree(radio->buffer); +err_nobuf: + kfree(radio); +err: + return retval; } static int __init amradio_init(void) From 0cdbd79a6e87a8a2862a6c1309c8fdf83c80ba61 Mon Sep 17 00:00:00 2001 From: David Ellingsworth Date: Sat, 12 Sep 2009 00:13:16 -0400 Subject: [PATCH 03/10] mr800: simplify error paths in usb probe callback Signed-off-by: David Ellingsworth --- drivers/media/radio/radio-mr800.c | 27 ++++++++++++++++----------- 1 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 3129692..d01b96c 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -689,30 +689,29 @@ static int usb_amradio_probe(struct usb_interface *intf, { struct amradio_device *radio; struct v4l2_device *v4l2_dev; - int retval; + int retval = 0; radio = kzalloc(sizeof(struct amradio_device), GFP_KERNEL); if (!radio) { dev_err(&intf->dev, "kmalloc for amradio_device failed\n"); - return -ENOMEM; + retval = -ENOMEM; + goto err; } radio->buffer = kmalloc(BUFFER_LENGTH, GFP_KERNEL); if (!radio->buffer) { dev_err(&intf->dev, "kmalloc for radio->buffer failed\n"); - kfree(radio); - return -ENOMEM; + retval = -ENOMEM; + goto err_nobuf; } v4l2_dev = &radio->v4l2_dev; retval = v4l2_device_register(&intf->dev, v4l2_dev); if (retval < 0) { dev_err(&intf->dev, "couldn't register v4l2_device\n"); - kfree(radio->buffer); - kfree(radio); - return retval; + goto err_v4l2; } strlcpy(radio->videodev.name, v4l2_dev->name, @@ -736,14 +735,20 @@ static int usb_amradio_probe(struct usb_interface *intf, radio_nr); if (retval < 0) { dev_err(&intf->dev, "could not register video device\n"); - v4l2_device_unregister(v4l2_dev); - kfree(radio->buffer); - kfree(radio); - return -EIO; + goto err_vdev; } usb_set_intfdata(intf, radio); return 0; + +err_vdev: + v4l2_device_unregister(v4l2_dev); +err_v4l2: + kfree(radio->buffer); +err_nobuf: + kfree(radio); +err: + return retval; } static int __init amradio_init(void) -- 1.6.3.3