Re: [PATCH v2 3/4] ASoC: Intel: atom: Use scoped_guard() for scoped locking

From: Cezary Rojewski

Date: Mon Jun 22 2026 - 03:36:31 EST


On 6/18/2026 1:06 PM, phucduc.bui@xxxxxxxxx wrote:
From: bui duc phuc <phucduc.bui@xxxxxxxxx>

Convert mutex-protected sections to scoped_guard() helpers and
simplify cleanup paths. Also use __free(kfree) for the temporary
stream pointer in sst_media_open().

No functional change intended.

...

diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index f074af2499c8..ce2814e206e1 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -304,7 +304,7 @@ static int sst_media_open(struct snd_pcm_substream *substream,
{
int ret_val = 0;
struct snd_pcm_runtime *runtime = substream->runtime;
- struct sst_runtime_stream *stream;
+ struct sst_runtime_stream *stream __free(kfree) = NULL;

No mixing of cleanup classes. Cleaning locking != cleaning pointers.
One action per patch.

...

@@ -347,13 +346,10 @@ static int sst_media_open(struct snd_pcm_substream *substream,
snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIODS, 2);
+ stream = NULL;
+

Is this needed? If you believe so, then I'd rather see it placed immediately after any operation that could cause the variable to leave the scope.

return snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
-out_ops:
- mutex_unlock(&sst_lock);
-out_power_up:
- kfree(stream);
- return ret_val;
}
static void sst_media_close(struct snd_pcm_substream *substream,