Commit bbd562d7 authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

watchdog: cpwd: Fix buffer-overflow

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: default avatarWim Van Sebroeck <wim@iguana.be>
parent c44ed965
...@@ -646,7 +646,7 @@ static int __devexit cpwd_remove(struct platform_device *op) ...@@ -646,7 +646,7 @@ static int __devexit cpwd_remove(struct platform_device *op)
struct cpwd *p = dev_get_drvdata(&op->dev); struct cpwd *p = dev_get_drvdata(&op->dev);
int i; int i;
for (i = 0; i < 4; i++) { for (i = 0; i < WD_NUMDEVS; i++) {
misc_deregister(&p->devs[i].misc); misc_deregister(&p->devs[i].misc);
if (!p->enabled) { if (!p->enabled) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment