Skip to contentSkip to conversation

ALSA: compress: Set metadata_set only after successful callback

PATCH Superseded Sreeraj S Kurup 3 participants 5 messages Nov 13 – Nov 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: compress: Set metadata_set only after successful callback

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.

---
 sound/core/compress_offload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/compress_offload.c +2 -2
index 5e5e0f78f26d..9b53282e0192 100644
@@ -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;
 }
 
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ALSA: compress: missing Fixes trailer for commit 9727b490e543 --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] ALSA: compress: missing Fixes trailer for commit 9727b490e543 --

commit 965fa8b5eac2d0c56694f06c6f1691a5d9ac92a3
Author: Sreeraj S Kurup <[email protected]>

Quoted 10 lines

ALSA: compress: Set metadata_set only after successful callback

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.

Quoted 4 lines

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

[Severity: Low]
Should this commit include a Fixes tag for the commit that introduced the unconditional assignment in snd_compr_set_metadata()?

Fixes 9727b490e543 ("ALSA: compress: add support for gapless playback")

Also, this isn't a bug in the patch, but stream->metadata_set is only read in snd_compr_next_track() to gate SNDRV_COMPRESS_NEXT_TRACK (returning -EPERM when false), rather than causing later operations to skip metadata setup.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw

PATCH v2 1/1 ALSA: compress: Set metadata_set only after successful callback

In reply to Sreeraj S Kurup

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")

---
v2:
- Add Fixes trailer.

 sound/core/compress_offload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/compress_offload.c +2 -2
index 5e5e0f78f26d..9b53282e0192 100644
@@ -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;
 }
 
Signature · 1 line
2.55.0
#3 lore raw
Quoted 9 lines · Sreeraj S Kurup

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.

Quoted 5 lines

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")

Applied now. Thanks.

Takashi