mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>,
	LMML <linux-media@vger.kernel.org>,
	DLOS <davinci-linux-open-source@linux.davincidsp.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: davinci: vpif: fix array out of bound warnings
Date: Sun, 3 Aug 2014 15:04:33 +0300	[thread overview]
Message-ID: <20140803120432.GZ16460@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <1405701111-26983-1-git-send-email-prabhakar.csengg@gmail.com>

Hi Prabhakar,

On Fri, Jul 18, 2014 at 05:31:51PM +0100, Lad, Prabhakar wrote:
> This patch fixes following array out of bound warnings,
> 
> drivers/media/platform/davinci/vpif_display.c: In function 'vpif_remove':
> drivers/media/platform/davinci/vpif_display.c:1389:36: warning: iteration
> 1u invokes undefined behavior [-Waggressive-loop-optimizations]
>    vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
>                                     ^
> drivers/media/platform/davinci/vpif_display.c:1385:2: note: containing loop
>   for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {
>   ^
> drivers/media/platform/davinci/vpif_capture.c: In function 'vpif_remove':
> drivers/media/platform/davinci/vpif_capture.c:1581:36: warning: iteration
> 1u invokes undefined behavior [-Waggressive-loop-optimizations]
>    vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
>                                     ^
> drivers/media/platform/davinci/vpif_capture.c:1577:2: note: containing loop
>   for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) {
>   ^
> drivers/media/platform/davinci/vpif_capture.c:1580:23: warning: array subscript
> is above array bounds [-Warray-bounds]
>    common = &ch->common[i];
> 
> Reported-by: Hans Verkuil <hans.verkuil@cisco.com>
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> ---
>  drivers/media/platform/davinci/vpif_capture.c | 2 +-
>  drivers/media/platform/davinci/vpif_display.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index 2f90f0d..3a85238 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1577,7 +1577,7 @@ static int vpif_remove(struct platform_device *device)
>  	for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) {
>  		/* Get the pointer to the channel object */
>  		ch = vpif_obj.dev[i];
> -		common = &ch->common[i];
> +		common = &ch->common[VPIF_VIDEO_INDEX];

You could refer to the alloc_ctz directly w/o extra local variables. Also
local variables that are only used inside the loop could be declared there
as well.

Acked-by: Sakari Ailus <sakari.ailus@iki.fi>

>  		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
>  		/* Unregister video device */
>  		video_unregister_device(ch->video_dev);
> diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
> index 0bd6dcb..6c6bd6b 100644
> --- a/drivers/media/platform/davinci/vpif_display.c
> +++ b/drivers/media/platform/davinci/vpif_display.c
> @@ -1385,7 +1385,7 @@ static int vpif_remove(struct platform_device *device)
>  	for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) {
>  		/* Get the pointer to the channel object */
>  		ch = vpif_obj.dev[i];
> -		common = &ch->common[i];
> +		common = &ch->common[VPIF_VIDEO_INDEX];
>  		vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
>  		/* Unregister video device */
>  		video_unregister_device(ch->video_dev);

-- 
Kind regards,

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

      reply	other threads:[~2014-08-03 12:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 16:31 Lad, Prabhakar
2014-08-03 12:04 ` 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=20140803120432.GZ16460@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=davinci-linux-open-source@linux.davincidsp.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=prabhakar.csengg@gmail.com \
    /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®