From bc0e4b2f1d500789fd24106fae5d84804719fdfe Mon Sep 17 00:00:00 2001
From: Misael Lopez Cruz <misael.lopez@ti.com>
Date: Thu, 24 Feb 2011 19:19:33 -0600
Subject: [PATCH 42/60] ASoC: McPDM: Fix race condition in playback stream shutdown

commit 42cecbd50119537f4afe75067ea6ea630ec71f24 upstream

In order to safely free McPDM interface during playback
stream shutdown, it's also required to check that no new
playback streams have been opened since the time the
delayed shutdown work was scheduled and the time it got
executed. Otherwise, McPDM interface could get freed
between stream startup and hw_params calls, which could
end up crashing the system.

Change-Id: I50d5ce897b5f4684a7afe3723eb1dd90de65dacd
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Integrated-by: Jingdong Lu <jingdong.lu@windriver.com>
---
 sound/soc/omap/omap-mcpdm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index 0dba7f0..f2e6ac3 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -741,7 +741,7 @@ static void playback_abe_work(struct work_struct *work)
 	}
 	mutex_unlock(&mcpdm->mutex);
 
-	if (!mcpdm->free && !mcpdm->ul_active)
+	if (!mcpdm->free && !mcpdm->ul_active && !mcpdm->dl_active)
 		omap_mcpdm_free(mcpdm);
 
 }
-- 
1.7.4.1

