Thread (1 message) 1 message, 1 author, 2019-03-06

Re: [alsa-devel] [RFC PATCH] ASoC: dpcm: prevent snd_soc_dpcm use after free

From: Kuninori Morimoto <hidden>
Date: 2019-03-06 08:20:51
Also in: alsa-devel

Hi

Small comment from me
quoted hunk
@@ -3257,9 +3268,12 @@ int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe,
 		if (state == SND_SOC_DPCM_STATE_START ||
 			state == SND_SOC_DPCM_STATE_PAUSED ||
 			state == SND_SOC_DPCM_STATE_SUSPEND ||
-			state == SND_SOC_DPCM_STATE_PREPARE)
+			state == SND_SOC_DPCM_STATE_PREPARE) {
+			spin_unlock(&fe->card->dpcm_lock);
 			return 0;
+		}
 	}
+			spin_unlock(&fe->card->dpcm_lock);
1st is you want to alignment last spin_unlock() position.
2ns is you want to have clean code which can avoid multiple unlock

	ret = 1; // default

	spin_lock()
	for_each_dpcm_fe(be, stream, dpcm) {
		...
		if (xxx) {
			ret = 0;
			break;
		}
	}
	spin_unlock()

	return ret;

Best regards
---
Kuninori Morimoto
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help