media: imagination: Fix value clamping in calculate_qp_tables()
Subsystems (2)
PATCH RESEND 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.
--- 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
@@ -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; }
Hi Thorsten,
Thank you for the fix.
Quoting Thorsten Blum (2026-07-27 15:17:30)
Quoted 6 lines
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")Signed-off-by Thorsten Blum <[email protected]>
Thanks,
Jai
Quoted 24 lines
--- 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@@ -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; }
Quoted 9 lines · Jai Luthra
Quoting Thorsten Blum (2026-07-27 15:17:30)
Quoted 6 lines
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")Signed-off-by Thorsten Blum <[email protected]>Reviewed-by Jai Luthra <[email protected]>
Thank you for the review.
Could someone please pick this up?
Thanks,
Thorsten
Le lundi 31 août 2026 à 10:13 +0200, Thorsten Blum a écrit :
Quoted 6 lines · Jai Luthra
Quoted 5 lines
Quoting Thorsten Blum (2026-07-27 15:17:30)
Quoted 4 lines
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.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes a1e294045885 ("media: imagination: Add E5010 JPEG Encoder driver")Signed-off-by Thorsten Blum <[email protected]>Reviewed-by Jai Luthra <[email protected]>Thank you for the review.
Could someone please pick this up?
Picked, ty
Nicolas
Quoted 3 lines
Thanks,
Thorsten