Skip to contentSkip to conversation

media: imagination: Fix value clamping in calculate_qp_tables

PATCH Superseded Thorsten Blum 1 participant 2 messages Dec 2, 2025 – Dec 19, 2025

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

PATCH 1/1 media: imagination: Fix value clamping in calculate_qp_tables

The local variable 'val' was never clamped to 1 or 255 because the return value of clamp() was not used. Fix this by assigning the clamped value back to 'val'.

Fixes a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
---
 drivers/media/platform/imagination/e5010-jpeg-enc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/imagination/e5010-jpeg-enc.c +2 -2
index c4e0097cb8b7..a36a2acc896c 100644
@@ -175,12 +175,12 @@ static void calculate_qp_tables(struct e5010_context *ctx)
 		long long delta = v4l2_jpeg_ref_table_chroma_qt[i] * contrast + luminosity;
 		int val = (int)(v4l2_jpeg_ref_table_chroma_qt[i] + delta);
 
-		clamp(val, 1, 255);
+		val = clamp(val, 1, 255);
 		ctx->chroma_qp[i] = quality == -50 ? 1 : val;
 
 		delta = v4l2_jpeg_ref_table_luma_qt[i] * contrast + luminosity;
 		val = (int)(v4l2_jpeg_ref_table_luma_qt[i] + delta);
-		clamp(val, 1, 255);
+		val = clamp(val, 1, 255);
 		ctx->luma_qp[i] = quality == -50 ? 1 : val;
 	}
 
Signature · 2 lines
Thorsten Blum <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
#1 lore raw
Quoted 9 lines · Thorsten Blum

The local variable 'val' was never clamped to 1 or 255 because the return value of clamp() was not used. Fix this by assigning the clamped value back to 'val'.

Fixes a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")

---
[...]

Hello, the media CI robot complained to me privately (not to the list) with the following error:

ERROR: Commit a1e2940458853d00c178c842c889e4ae3ef5eaec NOT found in the stable tree, but [email protected] is in Cc:

However, the Fixes: tag references the commit hash in master, but the commit has a different hash in the stable branches. This is my first time running into such an issue and I'm not sure what to do about it?

Thanks,
Thorsten