public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Rankin <rankincj@yahoo.com>
To: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: linux-media@vger.kernel.org, mchehab@redhat.com,
	Antti Palosaari <crope@iki.fi>
Subject: Re: [PATCH] Latest version of em28xx / em28xx-dvb patch for PCTV 290e
Date: Fri, 19 Aug 2011 00:45:27 +0100	[thread overview]
Message-ID: <4E4DA417.6030809@yahoo.com> (raw)
In-Reply-To: <CAGoCfiw4v-ZsUPmVgOhARwNqjCVK458EV79djD625Sf+8Oghag@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 943 bytes --]

This patch closes the race on the device and extension lists at USB disconnect 
time. Previously, the device was removed from the device list during 
em28xx_release_resources(), and then passed to the em28xx_close_extension() 
function so that all extensions could run their fini() operations. However, this 
left a (brief, theoretical, highly unlikely ;-)) window between these two calls 
during which a new module could call em28xx_register_extension(). The result 
would have been that the em28xx_usb_disconnect() function would also have passed 
the device to the new extension's fini() function, despite never having called 
the extension's init() function.

This patch also restores em28xx_close_extension()'s symmetry with 
em28xx_init_extension(), and establishes the property that every device in the 
device list must have been initialised for every extension in the extension list.

Signed-of-by: Chris Rankin <rankincj@yahoo.com>


[-- Attachment #2: EM28xx-race-on-disconnect.diff --]
[-- Type: text/x-patch, Size: 2136 bytes --]

--- linux-3.0/drivers/media/video/em28xx/em28xx-cards.c.orig	2011-08-19 00:23:17.000000000 +0100
+++ linux-3.0/drivers/media/video/em28xx/em28xx-cards.c	2011-08-19 00:32:40.000000000 +0100
@@ -2738,9 +2738,9 @@
 #endif /* CONFIG_MODULES */
 
 /*
- * em28xx_realease_resources()
+ * em28xx_release_resources()
  * unregisters the v4l2,i2c and usb devices
- * called when the device gets disconected or at module unload
+ * called when the device gets disconnected or at module unload
 */
 void em28xx_release_resources(struct em28xx *dev)
 {
@@ -2754,8 +2754,6 @@
 
 	em28xx_release_analog_resources(dev);
 
-	em28xx_remove_from_devlist(dev);
-
 	em28xx_i2c_unregister(dev);
 
 	v4l2_device_unregister(&dev->v4l2_dev);
@@ -3152,7 +3150,7 @@
 
 /*
  * em28xx_usb_disconnect()
- * called when the device gets diconencted
+ * called when the device gets disconnected
  * video device will be unregistered on v4l2_close in case it is still open
  */
 static void em28xx_usb_disconnect(struct usb_interface *interface)
--- linux-3.0/drivers/media/video/em28xx/em28xx-core.c.orig	2011-08-18 23:07:51.000000000 +0100
+++ linux-3.0/drivers/media/video/em28xx/em28xx-core.c	2011-08-19 00:27:00.000000000 +0100
@@ -1160,18 +1160,6 @@
 static DEFINE_MUTEX(em28xx_devlist_mutex);
 
 /*
- * em28xx_realease_resources()
- * unregisters the v4l2,i2c and usb devices
- * called when the device gets disconected or at module unload
-*/
-void em28xx_remove_from_devlist(struct em28xx *dev)
-{
-	mutex_lock(&em28xx_devlist_mutex);
-	list_del(&dev->devlist);
-	mutex_unlock(&em28xx_devlist_mutex);
-};
-
-/*
  * Extension interface
  */
 
@@ -1221,14 +1209,13 @@
 
 void em28xx_close_extension(struct em28xx *dev)
 {
-	struct em28xx_ops *ops = NULL;
+	const struct em28xx_ops *ops = NULL;
 
 	mutex_lock(&em28xx_devlist_mutex);
-	if (!list_empty(&em28xx_extension_devlist)) {
-		list_for_each_entry(ops, &em28xx_extension_devlist, next) {
-			if (ops->fini)
-				ops->fini(dev);
-		}
+	list_for_each_entry(ops, &em28xx_extension_devlist, next) {
+		if (ops->fini)
+			ops->fini(dev);
 	}
+	list_del(&dev->devlist);
 	mutex_unlock(&em28xx_devlist_mutex);
 }

  parent reply	other threads:[~2011-08-18 23:45 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-18 17:52 [PATCH] Latest version of em28xx / em28xx-dvb patch for PCTV 290e Chris Rankin
2011-08-18 18:43 ` Devin Heitmueller
2011-08-18 18:44   ` Devin Heitmueller
2011-08-18 21:34     ` Chris Rankin
2011-08-18 22:11     ` Chris Rankin
2011-08-19  5:53       ` Mauro Carvalho Chehab
2011-08-20 11:08         ` [PATCH 1/6 ] EM28xx - pass correct buffer size to snprintf Chris Rankin
2011-08-20 11:14         ` [PATCH 2/6] Fix memory leak on disconnect or error Chris Rankin
2011-08-20 11:21         ` [PATCH 3/6] EM28xx - use atomic bit operations for devices-in-use mask Chris Rankin
2011-08-20 11:28         ` [PATCH 4/6] EM28xx - clean up resources should init fail Chris Rankin
2011-08-20 11:31         ` [PATCH 5/6] EM28xx - move printk lines outside mutex lock Chris Rankin
2011-08-20 11:37         ` [PATCH 6/6] EM28xx - don't sleep on disconnect Chris Rankin
2011-08-20 12:17           ` Mauro Carvalho Chehab
2011-08-20 13:46             ` Chris Rankin
2011-08-20 14:20               ` Mauro Carvalho Chehab
2011-08-20 19:01                 ` Chris Rankin
2011-08-20 11:42         ` [PATCH 1/2] EM28xx - fix race " Chris Rankin
2011-08-20 12:36           ` Sylwester Nawrocki
2011-08-20 11:46         ` [PATCH 2/2] EM28xx - fix deadlock when unplugging and replugging a DVB adapter Chris Rankin
2011-08-20 12:34           ` Mauro Carvalho Chehab
2011-08-20 14:40             ` Chris Rankin
2011-08-20 15:02               ` Mauro Carvalho Chehab
2011-08-20 22:38                 ` [PATCH 1/1] " Chris Rankin
2011-08-21 12:32                 ` Chris Rankin
2011-09-13 20:04                   ` Antti Palosaari
2011-09-13 20:47                     ` Chris Rankin
2011-08-18 22:28     ` [PATCH] Latest version of em28xx / em28xx-dvb patch for PCTV 290e Chris Rankin
2011-08-18 23:45     ` Chris Rankin [this message]
2011-08-19  0:12     ` Chris Rankin
2011-08-18 19:56   ` Chris Rankin
2011-08-19  1:01     ` Mauro Carvalho Chehab

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=4E4DA417.6030809@yahoo.com \
    --to=rankincj@yahoo.com \
    --cc=crope@iki.fi \
    --cc=dheitmueller@kernellabs.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    /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