Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Aug 2009 15:48:10 +0000 (UTC)
From:      Stanislav Sedov <stas@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r196250 - in stable/7/sys: . contrib/pf dev/sound/pci
Message-ID:  <200908151548.n7FFmAVK076135@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: stas
Date: Sat Aug 15 15:48:10 2009
New Revision: 196250
URL: http://svn.freebsd.org/changeset/base/196250

Log:
  - MFC r191308, r191310:
      Properly unlock mutex on failure in channel_trigger. Before this
      the function just returned with the mutex held.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/sound/pci/envy24.c
  stable/7/sys/dev/sound/pci/envy24ht.c

Modified: stable/7/sys/dev/sound/pci/envy24.c
==============================================================================
--- stable/7/sys/dev/sound/pci/envy24.c	Sat Aug 15 15:41:10 2009	(r196249)
+++ stable/7/sys/dev/sound/pci/envy24.c	Sat Aug 15 15:48:10 2009	(r196250)
@@ -1721,6 +1721,7 @@ envy24chan_trigger(kobj_t obj, void *dat
 	struct sc_info *sc = ch->parent;
 	u_int32_t ptr;
 	int slot;
+	int error = 0;
 #if 0
 	int i;
 
@@ -1742,8 +1743,10 @@ envy24chan_trigger(kobj_t obj, void *dat
 			sc->caps[0].minspeed = sc->caps[0].maxspeed = sc->speed;
 			sc->caps[1].minspeed = sc->caps[1].maxspeed = sc->speed;
 		}
-		else if (ch->speed != 0 && ch->speed != sc->speed)
-			return -1;
+		else if (ch->speed != 0 && ch->speed != sc->speed) {
+			error = -1;
+			goto fail;
+		}
 		if (ch->speed == 0)
 			ch->channel->speed = sc->speed;
 		/* start or enable channel */
@@ -1773,16 +1776,20 @@ envy24chan_trigger(kobj_t obj, void *dat
 #if(0)
 		device_printf(sc->dev, "envy24chan_trigger(): emldmawr\n");
 #endif
-		if (ch->run != 1)
-			return -1;
+		if (ch->run != 1) {
+			error = -1;
+			goto fail;
+		}
 		ch->emldma(ch);
 		break;
 	case PCMTRIG_EMLDMARD:
 #if(0)
 		device_printf(sc->dev, "envy24chan_trigger(): emldmard\n");
 #endif
-		if (ch->run != 1)
-			return -1;
+		if (ch->run != 1) {
+			error = -1;
+			goto fail;
+		}
 		ch->emldma(ch);
 		break;
 	case PCMTRIG_ABORT:
@@ -1814,9 +1821,9 @@ envy24chan_trigger(kobj_t obj, void *dat
 		}
 		break;
 	}
+fail:
 	snd_mtxunlock(sc->lock);
-
-	return 0;
+	return (error);
 }
 
 static int

Modified: stable/7/sys/dev/sound/pci/envy24ht.c
==============================================================================
--- stable/7/sys/dev/sound/pci/envy24ht.c	Sat Aug 15 15:41:10 2009	(r196249)
+++ stable/7/sys/dev/sound/pci/envy24ht.c	Sat Aug 15 15:48:10 2009	(r196250)
@@ -1668,6 +1668,7 @@ envy24htchan_trigger(kobj_t obj, void *d
 	struct sc_info *sc = ch->parent;
 	u_int32_t ptr;
 	int slot;
+	int error = 0;
 #if 0
 	int i;
 
@@ -1689,8 +1690,10 @@ envy24htchan_trigger(kobj_t obj, void *d
 			sc->caps[0].minspeed = sc->caps[0].maxspeed = sc->speed;
 			sc->caps[1].minspeed = sc->caps[1].maxspeed = sc->speed;
 		}
-		else if (ch->speed != 0 && ch->speed != sc->speed)
-			return -1;
+		else if (ch->speed != 0 && ch->speed != sc->speed) {
+			error = -1;
+			goto fail;
+		}
 		if (ch->speed == 0)
 			ch->channel->speed = sc->speed;
 		/* start or enable channel */
@@ -1720,16 +1723,20 @@ envy24htchan_trigger(kobj_t obj, void *d
 #if(0)
 		device_printf(sc->dev, "envy24htchan_trigger(): emldmawr\n");
 #endif
-		if (ch->run != 1)
-			return -1;
+		if (ch->run != 1) {
+			error = -1;
+			goto fail;
+		}
 		ch->emldma(ch);
 		break;
 	case PCMTRIG_EMLDMARD:
 #if(0)
 		device_printf(sc->dev, "envy24htchan_trigger(): emldmard\n");
 #endif
-		if (ch->run != 1)
-			return -1;
+		if (ch->run != 1) {
+			error = -1;
+			goto fail;
+		}
 		ch->emldma(ch);
 		break;
 	case PCMTRIG_ABORT:
@@ -1759,9 +1766,9 @@ envy24htchan_trigger(kobj_t obj, void *d
 		}
 		break;
 	}
+fail:
 	snd_mtxunlock(sc->lock);
-
-	return 0;
+	return (error);
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908151548.n7FFmAVK076135>