Skip to content

Commit

Permalink
watchdog: cpwd: Fix buffer-overflow
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wim Van Sebroeck committed Mar 14, 2011
1 parent c44ed96 commit bbd562d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/watchdog/cpwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bbd562d

Please sign in to comment.