aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-24 16:36:36 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-24 16:36:36 -0700
commit144d80bed91a6557269c935bf03e0f56089e5be0 (patch)
treeabdfbf7947542d11e8e41ab7adb729d11e82afc4
parentcbb525b447996f5d5702f7f2d7073f395fadcfe1 (diff)
parent168bfeef7bba3f9784f7540b053e4ac72b769ce9 (diff)
downloaddrm-144d80bed91a6557269c935bf03e0f56089e5be0.tar.gz
Merge tag 'edac_scrubrates_fix' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp
Pull amd64_edac fix from Borislav Petkov: "An array out-of-bounds fix from Andrew when setting the scrub rate of the memory controller." * tag 'edac_scrubrates_fix' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp: amd64_edac:__amd64_set_scrub_rate(): avoid overindexing scrubrates[]
-rw-r--r--drivers/edac/amd64_edac.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 5a297a26211d62..cc8e7c78a23ca2 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -170,8 +170,11 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
* memory controller and apply to register. Search for the first
* bandwidth entry that is greater or equal than the setting requested
* and program that. If at last entry, turn off DRAM scrubbing.
+ *
+ * If no suitable bandwidth is found, turn off DRAM scrubbing entirely
+ * by falling back to the last element in scrubrates[].
*/
- for (i = 0; i < ARRAY_SIZE(scrubrates); i++) {
+ for (i = 0; i < ARRAY_SIZE(scrubrates) - 1; i++) {
/*
* skip scrub rates which aren't recommended
* (see F10 BKDG, F3x58)
@@ -181,12 +184,6 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
if (scrubrates[i].bandwidth <= new_bw)
break;
-
- /*
- * if no suitable bandwidth found, turn off DRAM scrubbing
- * entirely by falling back to the last element in the
- * scrubrates array.
- */
}
scrubval = scrubrates[i].scrubval;