s3c-fb: fix off-by-one bug in loop indexes
authorPawel Osciak <[email protected]>
Wed, 29 Jul 2009 22:02:10 +0000 (15:02 -0700)
committerLinus Torvalds <[email protected]>
Thu, 30 Jul 2009 02:10:34 +0000 (19:10 -0700)
Fixed off-by-one bug in loop indexes - some elements beyond windows' array
were accessed, which might result in memory access violations when
removing/suspending the device.

Signed-off-by: Pawel Osciak <[email protected]>
Reviewed-by: Kyungmin Park <[email protected]>
Signed-off-by: Marek Szyprowski <[email protected]>
Cc: Krzysztof Helt <[email protected]>
Cc: Ben Dooks <[email protected]>
Cc: Russell King <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/video/s3c-fb.c

index bb63c07e13de5272e1ce5c5bcb2771da14dcc2ab..5a72083dc67c76c4b7f9f9f2fbb4c5604cab5eca 100644 (file)
@@ -964,7 +964,7 @@ static int __devexit s3c_fb_remove(struct platform_device *pdev)
        struct s3c_fb *sfb = platform_get_drvdata(pdev);
        int win;
 
-       for (win = 0; win <= S3C_FB_MAX_WIN; win++)
+       for (win = 0; win < S3C_FB_MAX_WIN; win++)
                if (sfb->windows[win])
                        s3c_fb_release_win(sfb, sfb->windows[win]);
 
@@ -988,7 +988,7 @@ static int s3c_fb_suspend(struct platform_device *pdev, pm_message_t state)
        struct s3c_fb_win *win;
        int win_no;
 
-       for (win_no = S3C_FB_MAX_WIN; win_no >= 0; win_no--) {
+       for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
                win = sfb->windows[win_no];
                if (!win)
                        continue;