[PATCH] media: imagination: Fix value clamping in calculate_qp_tables

Thorsten Blum posted 1 patch 2 months, 1 week ago
There is a newer version of this series
drivers/media/platform/imagination/e5010-jpeg-enc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] media: imagination: Fix value clamping in calculate_qp_tables
Posted by Thorsten Blum 2 months, 1 week ago
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'.

Cc: stable@vger.kernel.org
Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/media/platform/imagination/e5010-jpeg-enc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c
index c4e0097cb8b7..a36a2acc896c 100644
--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c
+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c
@@ -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;
 	}
 
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
Re: [PATCH] media: imagination: Fix value clamping in calculate_qp_tables
Posted by Thorsten Blum 1 month, 2 weeks ago
On 2. Dec 2025, at 13:45, Thorsten Blum wrote:
> 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'.
> 
> Cc: stable@vger.kernel.org
> Fixes: a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> [...]

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 stable@vger.kernel.org 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