lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20140803120432.GZ16460@valkosipuli.retiisi.org.uk>
Date:	Sun, 3 Aug 2014 15:04:33 +0300
From:	Sakari Ailus <sakari.ailus@....fi>
To:	"Lad, Prabhakar" <prabhakar.csengg@...il.com>
Cc:	Hans Verkuil <hans.verkuil@...co.com>,
	LMML <linux-media@...r.kernel.org>,
	DLOS <davinci-linux-open-source@...ux.davincidsp.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] media: davinci: vpif: fix array out of bound warnings

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@...co.com>
> Signed-off-by: Lad, Prabhakar <prabhakar.csengg@...il.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@....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@....fi	XMPP: sailus@...iisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ