From patchwork Tue Jul 19 16:12:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 989212 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6JGCxA0020741 for ; Tue, 19 Jul 2011 16:13:00 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751464Ab1GSQM6 (ORCPT ); Tue, 19 Jul 2011 12:12:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50697 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751298Ab1GSQM5 (ORCPT ); Tue, 19 Jul 2011 12:12:57 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6JGCq42001953 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 19 Jul 2011 12:12:52 -0400 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6JGCpLL020347; Tue, 19 Jul 2011 12:12:52 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Cc: Jarod Wilson , Andy Walls , Chris W Subject: [PATCH] [media] imon: don't parse scancodes until intf configured Date: Tue, 19 Jul 2011 12:12:47 -0400 Message-Id: <1311091967-2791-1-git-send-email-jarod@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 19 Jul 2011 16:13:00 +0000 (UTC) The imon devices have either 1 or 2 usb interfaces on them, each wired up to its own urb callback. The interface 0 urb callback is wired up before the imon context's rc_dev pointer is filled in, which is necessary for imon 0xffdc device auto-detection to work properly, but we need to make sure we don't actually run the callback routines until we've entirely filled in the necessary bits for each given interface, lest we wind up oopsing. Technically, any imon device could have hit this, but the issue is exacerbated on the 0xffdc devices, which send a constant stream of interrupts, even when they have no valid key data. CC: Andy Walls CC: Chris W Reported-by: Chris W Signed-off-by: Jarod Wilson --- drivers/media/rc/imon.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index caa3e3a..6ed9646 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -1658,7 +1658,7 @@ static void usb_rx_callback_intf0(struct urb *urb) return; ictx = (struct imon_context *)urb->context; - if (!ictx) + if (!ictx || !ictx->dev_present_intf0) return; switch (urb->status) { @@ -1690,7 +1690,7 @@ static void usb_rx_callback_intf1(struct urb *urb) return; ictx = (struct imon_context *)urb->context; - if (!ictx) + if (!ictx || !ictx->dev_present_intf1) return; switch (urb->status) { @@ -2118,7 +2118,6 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) ictx->dev = dev; ictx->usbdev_intf0 = usb_get_dev(interface_to_usbdev(intf)); - ictx->dev_present_intf0 = true; ictx->rx_urb_intf0 = rx_urb; ictx->tx_urb = tx_urb; ictx->rf_device = false; @@ -2157,6 +2156,8 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) goto rdev_setup_failed; } + ictx->dev_present_intf0 = true; + mutex_unlock(&ictx->lock); return ictx; @@ -2200,7 +2201,6 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf, } ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf)); - ictx->dev_present_intf1 = true; ictx->rx_urb_intf1 = rx_urb; ret = -ENODEV; @@ -2229,6 +2229,8 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf, goto urb_submit_failed; } + ictx->dev_present_intf1 = true; + mutex_unlock(&ictx->lock); return ictx;