mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Maciej Matraszek <m.matraszek@samsung.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	stable@vger.kernel.org,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: Re: [PATCH] [media] v4l2-common: fix overflow in v4l_bound_align_image()
Date: Wed, 10 Sep 2014 15:29:53 +0300	[thread overview]
Message-ID: <20140910122953.GA2939@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <1410275801-17627-1-git-send-email-m.matraszek@samsung.com>

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

      reply	other threads:[~2014-09-10 12:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 15:16 Maciej Matraszek
2014-09-10 12:29 ` Sakari Ailus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140910122953.GA2939@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=b.zolnierkie@samsung.com \
    --cc=hans.verkuil@cisco.com \
    --cc=k.kozlowski@samsung.com \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=m.matraszek@samsung.com \
    --cc=s.nawrocki@samsung.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®