All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Rankin <rankincj@yahoo.com>
To: linux-media@vger.kernel.org
Subject: [PATCH] Fix locking problem between em28xx and em28xx-dvb modules
Date: Tue, 16 Aug 2011 09:50:01 +0100	[thread overview]
Message-ID: <4E4A2F39.6090809@yahoo.com> (raw)

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

Hi,

I've thought about this patch a bit more overnight, and it occurred to me that 
while  em28xx_init_extension() now takes the device mutex followed by the device 
list mutex, my original fix would have had em28xx_register_extension() taking 
the device list mutex followed by the device mutex. And that sounds suspiciously 
like a potential deadlock to me. So I was wondering: does 
em28xx_register_extension() actually need to lock the device if the device list 
has already been locked?

I've also moved two printk()s outside the region where we hold the device list 
mutex, because locked bits should be as brief as possible and neither printk() 
does anything that needs the lock.

A new patch is attached, for review.

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


[-- Attachment #2: EM28xx-DVB.diff --]
[-- Type: text/x-patch, Size: 1424 bytes --]

--- linux-3.0/drivers/media/video/em28xx/em28xx-core.c.orig	2011-08-16 09:15:46.000000000 +0100
+++ linux-3.0/drivers/media/video/em28xx/em28xx-core.c	2011-08-16 09:21:08.000000000 +0100
@@ -1193,8 +1193,8 @@
 	list_for_each_entry(dev, &em28xx_devlist, devlist) {
 		ops->init(dev);
 	}
-	printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name);
 	mutex_unlock(&em28xx_devlist_mutex);
+	printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name);
 	return 0;
 }
 EXPORT_SYMBOL(em28xx_register_extension);
@@ -1207,9 +1207,9 @@
 	list_for_each_entry(dev, &em28xx_devlist, devlist) {
 		ops->fini(dev);
 	}
-	printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name);
 	list_del(&ops->next);
 	mutex_unlock(&em28xx_devlist_mutex);
+	printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name);
 }
 EXPORT_SYMBOL(em28xx_unregister_extension);
 
--- linux-3.0/drivers/media/video/em28xx/em28xx-dvb.c.orig	2011-08-16 09:16:03.000000000 +0100
+++ linux-3.0/drivers/media/video/em28xx/em28xx-dvb.c	2011-08-16 09:17:06.000000000 +0100
@@ -542,7 +542,6 @@
 	dev->dvb = dvb;
 	dvb->fe[0] = dvb->fe[1] = NULL;
 
-	mutex_lock(&dev->lock);
 	em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
 	/* init frontend */
 	switch (dev->model) {
@@ -711,7 +710,6 @@
 	em28xx_info("Successfully loaded em28xx-dvb\n");
 ret:
 	em28xx_set_mode(dev, EM28XX_SUSPEND);
-	mutex_unlock(&dev->lock);
 	return result;
 
 out_free:

                 reply	other threads:[~2011-08-16  8:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4E4A2F39.6090809@yahoo.com \
    --to=rankincj@yahoo.com \
    --cc=linux-media@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.