[PATCH v2] ALSA: compress: Set metadata_set only after successful callback

From: Sreeraj S Kurup

Date: Fri Nov 13 2026 - 07:33:51 EST


Set the metadata_set flag only when the driver's set_metadata()
callback completes successfully.

Previously, the flag was set even when the callback returned an
error. This incorrectly indicated that metadata had been applied
successfully, potentially causing later operations to skip metadata
setup.

Update the flag only when the callback returns zero so that its
state accurately reflects successful metadata submission.

Fixes: 9727b490e543 ("ALSA: compress: add support for gapless playback")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@xxxxxxxxx>
---
v2:
- Add Fixes trailer.

sound/core/compress_offload.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 5e5e0f78f26d..9b53282e0192 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -796,8 +796,8 @@ snd_compr_set_metadata(struct snd_compr_stream *stream, unsigned long arg)
return -EFAULT;

retval = stream->ops->set_metadata(stream, &metadata);
- stream->metadata_set = true;
-
+ if (!retval)
+ stream->metadata_set = true;
return retval;
}

--
2.55.0