Commit bbd562d717a84c6464211e8bd5efa0d9e25edc6d

Authored by Wim Van Sebroeck
1 parent c44ed965be

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: Wim Van Sebroeck <wim@iguana.be>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/watchdog/cpwd.c
... ... @@ -646,7 +646,7 @@
646 646 struct cpwd *p = dev_get_drvdata(&op->dev);
647 647 int i;
648 648  
649   - for (i = 0; i < 4; i++) {
  649 + for (i = 0; i < WD_NUMDEVS; i++) {
650 650 misc_deregister(&p->devs[i].misc);
651 651  
652 652 if (!p->enabled) {