All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] media: imagination: Fix value clamping in calculate_qp_tables()
@ 2026-07-27  9:47 Thorsten Blum
  2026-07-27 10:34 ` Jai Luthra
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-07-27  9:47 UTC (permalink / raw)
  To: Devarsh Thakkar, Mauro Carvalho Chehab, Hans Verkuil,
	Benjamin Gaignard, David Huang, Sebastian Fricke
  Cc: Thorsten Blum, linux-media, linux-kernel

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 <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 42ad9ee3993b..420cb8bfdb12 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;
 	}
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RESEND] media: imagination: Fix value clamping in calculate_qp_tables()
  2026-07-27  9:47 [PATCH RESEND] media: imagination: Fix value clamping in calculate_qp_tables() Thorsten Blum
@ 2026-07-27 10:34 ` Jai Luthra
  0 siblings, 0 replies; 2+ messages in thread
From: Jai Luthra @ 2026-07-27 10:34 UTC (permalink / raw)
  To: Benjamin Gaignard, David Huang, Devarsh Thakkar, Hans Verkuil,
	Mauro Carvalho Chehab, Sebastian Fricke, Thorsten Blum
  Cc: Thorsten Blum, linux-media, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]

Hi Thorsten,

Thank you for the fix.

Quoting Thorsten Blum (2026-07-27 15:17:30)
> 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 <thorsten.blum@linux.dev>

Reviewed-by: Jai Luthra <jai.luthra@ideasonboard.com>

Thanks,
    Jai

> ---
>  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 42ad9ee3993b..420cb8bfdb12 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;
>         }
>  
>

[-- Attachment #2: signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEETeDYGOXVdejUWq/FQ96R+SSacUUFAmpnNEoACgkQQ96R+SSa
cUVU5hAAq1Tnk0/BbQ/LNI8+k2uUFmfVmtgColViwaz26SlMmiwxEWPe5AcNSLle
G4/pdsslyIesBDgo/N9/JLQn1iJYz109pEZwtM/pR/dIEugL3MEcyP4wWWZkY9k5
CjKNg19Es3p6kD1OSTQ2ykFnz7dum3j/jqJfLvJcP56it893unJMuULNqHjVz0XF
qtJ+r2XxrVhH45+/VOegJYL9LGGnU/eP1D+VBrKrkPPfPEl25eGff5JTa2BW8qQh
NdaD6xLPuARpEUMjW6wkT66LeUBRs8DtT8YEWIDb9/V99sTagjZKu7vbhwQ60RK3
rXO1dNnT43gRXwYRx3lkmKs6x8Pg8mkgEFVTw4y94y8kcx20kvyXFfnC1ro0FnVt
WZYmWSrV3/inDOyI1wpUR/pnxUNKZDlct33Zspy2avd+arpDCCXCRlpb6Rj5rd/E
pqifkciZWM6mey994U8qnXAm7wpx+/jMc0Ug+vU7KfqAYAwFlXrtUdgVHcvNAct3
0LapBWxiVh0ZeGObOpFNlU+m55MfyvpcrbzRN2iTQKp6ollUx//9j+QXmGONckMB
/Cml6iY5Mqa02cNTf57wJCAZlalEPAt4UH0IRKmurfwC+W2pkj0Dzs6yv1Ia5IBh
C2byvmqWPabi15JX1kMzXLshRfGwOeL3zgE+e/2UXMyPSck/i+E=
=db9U
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-27 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27  9:47 [PATCH RESEND] media: imagination: Fix value clamping in calculate_qp_tables() Thorsten Blum
2026-07-27 10:34 ` Jai Luthra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.