From patchwork Tue Nov 16 02:15:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: axel lin X-Patchwork-Id: 326872 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 oAG2BHQj022727 for ; Tue, 16 Nov 2010 02:11:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759164Ab0KPCLQ (ORCPT ); Mon, 15 Nov 2010 21:11:16 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:41089 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759132Ab0KPCLP (ORCPT ); Mon, 15 Nov 2010 21:11:15 -0500 Received: by eye27 with SMTP id 27so60291eye.19 for ; Mon, 15 Nov 2010 18:11:14 -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=hStmWDxnnx6K3W5lTM3rozc0xDIp2URtUt84pI2yASk=; b=AE6UrUSt1MZhDM03I7AFDYyVv6G4I1r5yIyYIRReR4Jfc4Ju2xHDGupjaGpBdLXlfI 24YFdzcaF62Y+DFQ45wzFuxaIoTFNnebYkTYoSC7xT/5YiTrWjM2cHDWy4iKuD3jbC20 QrBFEiy/fZ8w+sDKIKV01TFvaMeiYJjSTNHUM= 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=nr5seBsj/4eg5detTi+fnNNEODFqz6bJDOJXM/6eDgizWBokj7m+8bcLlRk+TstK/O L7Iw7oNrbNRjIuMOQ8gCxLrHuGTUJEVFM9QBtTpzhBz5bJp3Zl+3x44W45pBgJPhviVI P672wcKth+61sniJ6mtTI6/DHEw01LWYGhjYc= Received: by 10.213.35.72 with SMTP id o8mr1920599ebd.62.1289873474316; Mon, 15 Nov 2010 18:11:14 -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 w20sm611512eeh.18.2010.11.15.18.11.09 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Nov 2010 18:11:13 -0800 (PST) Subject: [PATCH] Input: xpad - ensure xpad->bulk_out is initialized before submitting urb From: Axel Lin To: linux-kernel Cc: Dmitry Torokhov , Oliver Neukum , Marko Friedemann , Christoph Fritz , linux-input@vger.kernel.org Date: Tue, 16 Nov 2010 10:15:31 +0800 Message-Id: <1289873732.7485.4.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]); Tue, 16 Nov 2010 02:11:18 +0000 (UTC) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 4875de9..56abf3d 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -921,19 +921,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id usb_set_intfdata(intf, xpad); - /* - * Submit the int URB immediately rather than waiting for open - * because we get status messages from the device whether - * or not any controllers are attached. In fact, it's - * exactly the message that a controller has arrived that - * we're waiting for. - */ if (xpad->xtype == XTYPE_XBOX360W) { - xpad->irq_in->dev = xpad->udev; - error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); - if (error) - goto fail7; - /* * Setup the message to set the LEDs on the * controller when it shows up @@ -941,13 +929,13 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); if (!xpad->bulk_out) { error = -ENOMEM; - goto fail8; + goto fail7; } xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); if (!xpad->bdata) { error = -ENOMEM; - goto fail9; + goto fail8; } xpad->bdata[2] = 0x08; @@ -969,12 +957,24 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id usb_fill_bulk_urb(xpad->bulk_out, udev, usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress), xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad); + + /* + * Submit the int URB immediately rather than waiting for open + * because we get status messages from the device whether + * or not any controllers are attached. In fact, it's + * exactly the message that a controller has arrived that + * we're waiting for. + */ + xpad->irq_in->dev = xpad->udev; + error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); + if (error) + goto fail9; } return 0; - fail9: usb_free_urb(xpad->bulk_out); - fail8: usb_kill_urb(xpad->irq_in); + fail9: kfree(xpad->bdata); + fail8: usb_free_urb(xpad->bulk_out); fail7: input_unregister_device(input_dev); input_dev = NULL; fail6: xpad_led_disconnect(xpad);