Skip to contentSkip to conversation

OSS: mpu401, fix deadlock

PATCH In review Jiri Slaby 2 participants 2 messages Jun 29, 2009 Sound

lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 OSS: mpu401, fix deadlock

If somebody cares about oss at all.
--
mpu401_chk_version is called with a spin lock already held. Don't take it again.

---
 sound/oss/mpu401.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
sound/oss/mpu401.c +3 -13
index 6c0a770..1b2316f 100644
@@ -926,31 +926,21 @@ static struct midi_operations mpu401_midi_operations[MAX_MIDI_DEV];
 static void mpu401_chk_version(int n, struct mpu_config *devc)
 {
 	int tmp;
-	unsigned long flags;
 
 	devc->version = devc->revision = 0;
 
-	spin_lock_irqsave(&devc->lock,flags);
-	if ((tmp = mpu_cmd(n, 0xAC, 0)) < 0)
-	{
-		spin_unlock_irqrestore(&devc->lock,flags);
+	tmp = mpu_cmd(n, 0xAC, 0);
+	if (tmp < 0)
 		return;
-	}
 	if ((tmp & 0xf0) > 0x20)	/* Why it's larger than 2.x ??? */
-	{
-		spin_unlock_irqrestore(&devc->lock,flags);
 		return;
-	}
 	devc->version = tmp;
 
-	if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0)
-	{
+	if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0) {
 		devc->version = 0;
-		spin_unlock_irqrestore(&devc->lock,flags);
 		return;
 	}
 	devc->revision = tmp;
-	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 int attach_mpu401(struct address_info *hw_config, struct module *owner)
Signature · 1 line
1.6.3.2
#1 lore raw

At Mon, 29 Jun 2009 18:03:34 +0200,

Quoted 2 lines · Jiri Slaby

If somebody cares about oss at all.

... or want to save somebody else's time to find out the same bug :)

Quoted 5 lines

--
mpu401_chk_version is called with a spin lock already held. Don't take it again.

Applied now. Thanks.

Takashi

Quoted 46 lines
---
 sound/oss/mpu401.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
sound/oss/mpu401.c +3 -13
index 6c0a770..1b2316f 100644
@@ -926,31 +926,21 @@ static struct midi_operations mpu401_midi_operations[MAX_MIDI_DEV];
 static void mpu401_chk_version(int n, struct mpu_config *devc)
 {
 	int tmp;
-	unsigned long flags;
 
 	devc->version = devc->revision = 0;
 
-	spin_lock_irqsave(&devc->lock,flags);
-	if ((tmp = mpu_cmd(n, 0xAC, 0)) < 0)
-	{
-		spin_unlock_irqrestore(&devc->lock,flags);
+	tmp = mpu_cmd(n, 0xAC, 0);
+	if (tmp < 0)
 		return;
-	}
 	if ((tmp & 0xf0) > 0x20)	/* Why it's larger than 2.x ??? */
-	{
-		spin_unlock_irqrestore(&devc->lock,flags);
 		return;
-	}
 	devc->version = tmp;
 
-	if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0)
-	{
+	if ((tmp = mpu_cmd(n, 0xAD, 0)) < 0) {
 		devc->version = 0;
-		spin_unlock_irqrestore(&devc->lock,flags);
 		return;
 	}
 	devc->revision = tmp;
-	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 int attach_mpu401(struct address_info *hw_config, struct module *owner)
Signature · 1 line
1.6.3.2