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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Small comment from me

> @@ -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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux