[media] media: davinci: vpif: fix array out of bound warnings
authorPrabhakar Lad <prabhakar.csengg@gmail.com>
Fri, 18 Jul 2014 16:31:51 +0000 (13:31 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 22 Jul 2014 03:46:17 +0000 (00:46 -0300)
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>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/davinci/vpif_display.c

index 2f90f0d98ad5ac598d5da41b7b045be5a0bb40fe..3a85238afee372764ba960c5289d3c4b37ac269c 100644 (file)
@@ -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];
                vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
                /* Unregister video device */
                video_unregister_device(ch->video_dev);
index 0bd6dcb13cbcf8fd4108e85df6740662e2cb81b4..6c6bd6b47994e6e4e19ca61980985f26b7e99060 100644 (file)
@@ -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);