public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarod Wilson <jarod@redhat.com>
To: linux-media@vger.kernel.org
Cc: Jarod Wilson <jarod@redhat.com>,
	Andy Walls <awalls@md.metrocast.net>,
	Chris W <lkml@psychogeeks.com>,
	Randy Dunlap <rdunlap@xenotime.net>,
	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	[thread overview]
Message-ID: <1311007609-28210-1-git-send-email-jarod@redhat.com> (raw)
In-Reply-To: <A91CBD95-B2AF-4F43-8BEC-6C8007ABB33C@wilsonet.com>

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 <awalls@md.metrocast.net>
CC: Chris W <lkml@psychogeeks.com>
CC: Randy Dunlap <rdunlap@xenotime.net>
CC: linux-kernel@vger.kernel.org
Reported-by: Chris W <lkml@psychogeeks.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 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);
-- 
1.7.1


  reply	other threads:[~2011-07-18 16:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4E1B978C.2030407@psychogeeks.com>
2011-07-12 15:03 ` Imon module Oops and kernel hang Randy Dunlap
2011-07-12 19:55   ` Jarod Wilson
2011-07-12 22:35     ` Chris W
2011-07-13  4:20       ` Jarod Wilson
2011-07-13  5:42         ` Chris W
2011-07-13 22:11           ` Jarod Wilson
2011-07-14  2:41             ` Chris W
2011-07-17  0:43               ` Andy Walls
2011-07-17  1:38                 ` Chris W
2011-07-17 13:36                   ` Andy Walls
2011-07-18 15:04                     ` Jarod Wilson
2011-07-18 16:46                       ` Jarod Wilson [this message]
2011-07-18 22:29                         ` [PATCH] [media] imon: don't submit urb before rc_dev set up Chris W
2011-07-19 12:23                           ` Jarod Wilson
2011-07-19 16:12                             ` [PATCH] [media] imon: don't parse scancodes until intf configured Jarod Wilson
2011-07-19 22:05                               ` Chris W
2011-07-20 13:18                                 ` Jarod Wilson
2011-07-20 22:56                                   ` Chris W
2011-07-26 17:57                                     ` Jarod Wilson
2011-07-22 14:06                         ` [PATCH] [media] imon: don't submit urb before rc_dev set up Jarod Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311007609-28210-1-git-send-email-jarod@redhat.com \
    --to=jarod@redhat.com \
    --cc=awalls@md.metrocast.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lkml@psychogeeks.com \
    --cc=rdunlap@xenotime.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox