]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
watchdog: cpwd: Fix buffer-overflow
authorWim Van Sebroeck <wim@iguana.be>
Mon, 21 Feb 2011 10:52:43 +0000 (10:52 +0000)
committerWim Van Sebroeck <wim@iguana.be>
Mon, 14 Mar 2011 10:39:27 +0000 (10:39 +0000)
cppcheck-1.47 reports:
[drivers/watchdog/cpwd.c:650]: (error) Buffer access out-of-bounds: p.devs

The source code is
for (i = 0; i < 4; i++) {
misc_deregister(&p->devs[i].misc);

where devs is defined as WD_NUMDEVS big and WD_NUMDEVS is equal to 3.
So the 4 should be a 3 or WD_NUMDEVS.

Reported-By: David Binderman
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
drivers/watchdog/cpwd.c

index eca855a55c0d6abf96096e6b41847c93b06675db..3de4ba0260a50f482a12d0869b35287592cd4ff0 100644 (file)
@@ -646,7 +646,7 @@ static int __devexit cpwd_remove(struct platform_device *op)
        struct cpwd *p = dev_get_drvdata(&op->dev);
        int i;
 
-       for (i = 0; i < 4; i++) {
+       for (i = 0; i < WD_NUMDEVS; i++) {
                misc_deregister(&p->devs[i].misc);
 
                if (!p->enabled) {