From patchwork Fri Nov 12 02:48:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: axel lin X-Patchwork-Id: 318592 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAC2jGqC032186 for ; Fri, 12 Nov 2010 02:45:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754213Ab0KLCoh (ORCPT ); Thu, 11 Nov 2010 21:44:37 -0500 Received: from mail-vw0-f46.google.com ([209.85.212.46]:59328 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753787Ab0KLCog (ORCPT ); Thu, 11 Nov 2010 21:44:36 -0500 Received: by vws13 with SMTP id 13so764086vws.19 for ; Thu, 11 Nov 2010 18:44:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=GwmOAyKRUJUd/1x8MLcR9tSJxAR8vOnAzcWRdYBEMfc=; b=MaG5pEefqakTrag1mF3oIoXcocUtAesQ3birvfX0/bQDpZGQv5/x3hgM6JG4fX1dG7 ueNTHmtM81ZK7YvttipfEvDSBn355XpCpCjpqv86U4P/DOqtW+BghQiAikJUrp0TZj3S b3kaa+CavDw/EH3ll0XxTpvVFW2ZkZTuzgwhI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=nom4hJtmAPUaxiavJxV1SGl1MkvRTyNgmkbbI6620rw0Y98r0puOffvPoE/z/cCN1t 2MEbr8ZGiFH5xTtv3iv+Wsry6IB3SAu3VeMwaTEmyd/g9k9N2Dx6XPbrRLcZrkusWboE PLZhUF7Zlo1Hu737K/izSpvCptHkkhSfXhkIQ= Received: by 10.220.45.132 with SMTP id e4mr381157vcf.29.1289529875128; Thu, 11 Nov 2010 18:44:35 -0800 (PST) Received: from [192.168.100.50] (60-251-136-127.HINET-IP.hinet.net [60.251.136.127]) by mx.google.com with ESMTPS id y14sm834904vch.28.2010.11.11.18.44.31 (version=SSLv3 cipher=RC4-MD5); Thu, 11 Nov 2010 18:44:34 -0800 (PST) Subject: [PATCH 1/3] Input: xpad - return proper error in error path From: Axel Lin To: linux-kernel Cc: Dmitry Torokhov , Marko Friedemann , Christoph Fritz , linux-input@vger.kernel.org Date: Fri, 12 Nov 2010 10:48:36 +0800 Message-Id: <1289530116.20782.2.camel@mola> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Nov 2010 02:45:17 +0000 (UTC) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index f9fb7fa..39c0265 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -543,21 +543,25 @@ exit: static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) { struct usb_endpoint_descriptor *ep_irq_out; - int error = -ENOMEM; + int error; if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) return 0; xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, GFP_KERNEL, &xpad->odata_dma); - if (!xpad->odata) + if (!xpad->odata) { + error = -ENOMEM; goto fail1; + } mutex_init(&xpad->odata_mutex); xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); - if (!xpad->irq_out) + if (!xpad->irq_out) { + error = -ENOMEM; goto fail2; + } ep_irq_out = &intf->cur_altsetting->endpoint[1].desc; usb_fill_int_urb(xpad->irq_out, xpad->udev, @@ -789,8 +793,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id struct usb_xpad *xpad; struct input_dev *input_dev; struct usb_endpoint_descriptor *ep_irq_in; - int i; - int error = -ENOMEM; + int i, error; for (i = 0; xpad_device[i].idVendor; i++) { if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && @@ -800,17 +803,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); input_dev = input_allocate_device(); - if (!xpad || !input_dev) + if (!xpad || !input_dev) { + error = -ENOMEM; goto fail1; + } xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, GFP_KERNEL, &xpad->idata_dma); - if (!xpad->idata) + if (!xpad->idata) { + error = -ENOMEM; goto fail1; + } xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); - if (!xpad->irq_in) + if (!xpad->irq_in) { + error = -ENOMEM; goto fail2; + } xpad->udev = udev; xpad->mapping = xpad_device[i].mapping; @@ -929,12 +938,16 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id * controller when it shows up */ xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); - if(!xpad->bulk_out) + if (!xpad->bulk_out) { + error = -ENOMEM; goto fail5; + } xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); - if(!xpad->bdata) + if (!xpad->bdata) { + error = -ENOMEM; goto fail6; + } xpad->bdata[2] = 0x08; switch (intf->cur_altsetting->desc.bInterfaceNumber) {