From patchwork Mon Jul 18 16:46:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 7465 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Mon, 18 Jul 2011 16:47:33 +0000 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.20) for (single-drop); Mon, 18 Jul 2011 13:48:37 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qiqyj-0005rQ-7e; Mon, 18 Jul 2011 16:47:33 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753216Ab1GRQrF (ORCPT + 1 other); Mon, 18 Jul 2011 12:47:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5652 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899Ab1GRQrD (ORCPT ); Mon, 18 Jul 2011 12:47:03 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6IGktTB029098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Jul 2011 12:46:55 -0400 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6IGksH6025218; Mon, 18 Jul 2011 12:46:54 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Cc: Jarod Wilson , Andy Walls , Chris W , Randy Dunlap , linux-kernel@vger.kernel.org Subject: [PATCH] [media] imon: don't submit urb before rc_dev set up Date: Mon, 18 Jul 2011 12:46:49 -0400 Message-Id: <1311007609-28210-1-git-send-email-jarod@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The interface 0 urb callback was being wired up before the rc_dev device was allocated, meaning the callback could be called with a null rc_dev, leading to an oops. This likely only ever happens on the older 0xffdc SoundGraph devices, which continually trigger interrupts even when they have no valid keydata, and the window in which it could happen is small, but its actually happening regularly for at least one user, and its an obvious fix. Compile and sanity-tested with one of my own imon devices. CC: Andy Walls CC: Chris W CC: Randy Dunlap CC: linux-kernel@vger.kernel.org Reported-by: Chris W Signed-off-by: Jarod Wilson --- drivers/media/rc/imon.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index caa3e3a..26238f5 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -2132,6 +2132,18 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) goto find_endpoint_failed; } + ictx->idev = imon_init_idev(ictx); + if (!ictx->idev) { + dev_err(dev, "%s: input device setup failed\n", __func__); + goto idev_setup_failed; + } + + ictx->rdev = imon_init_rdev(ictx); + if (!ictx->rdev) { + dev_err(dev, "%s: rc device setup failed\n", __func__); + goto rdev_setup_failed; + } + usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, usb_rcvintpipe(ictx->usbdev_intf0, ictx->rx_endpoint_intf0->bEndpointAddress), @@ -2145,26 +2157,14 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) goto urb_submit_failed; } - ictx->idev = imon_init_idev(ictx); - if (!ictx->idev) { - dev_err(dev, "%s: input device setup failed\n", __func__); - goto idev_setup_failed; - } - - ictx->rdev = imon_init_rdev(ictx); - if (!ictx->rdev) { - dev_err(dev, "%s: rc device setup failed\n", __func__); - goto rdev_setup_failed; - } - mutex_unlock(&ictx->lock); return ictx; +urb_submit_failed: + rc_unregister_device(ictx->rdev); rdev_setup_failed: input_unregister_device(ictx->idev); idev_setup_failed: - usb_kill_urb(ictx->rx_urb_intf0); -urb_submit_failed: find_endpoint_failed: mutex_unlock(&ictx->lock); usb_free_urb(tx_urb);