lkml.org 
[lkml]   [2014]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] [media] v4l2-common: fix overflow in v4l_bound_align_image()
Hi Maciej,

Thanks for the patch!

On Tue, Sep 09, 2014 at 05:16:41PM +0200, Maciej Matraszek wrote:
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index ccaa38f65cf1..506cf8b7763b 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -435,16 +435,13 @@ static unsigned int clamp_align(unsigned int x, unsigned int min,
> /* Bits that must be zero to be aligned */
> unsigned int mask = ~((1 << align) - 1);
>
> + /* Clamp to aligned min and max */
> + x = clamp_t(unsigned int, x, (min + ~mask) & mask, max & mask);

I think you could use just clamp() since all the arguments are unsigned int.
With that considered,

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> +
> /* Round to nearest aligned value */
> if (align)
> x = (x + (1 << (align - 1))) & mask;
>
> - /* Clamp to aligned value of min and max */
> - if (x < min)
> - x = (min + ~mask) & mask;
> - else if (x > max)
> - x = max & mask;
> -
> return x;
> }
>

--
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk


\
 
 \ /
  Last update: 2014-09-10 14:41    [W:0.046 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site