diff options
| author | Sasha Levin <levinsasha928@gmail.com> | 2012-05-10 16:01:44 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-10 18:06:44 -0400 |
| commit | 93278814d3590eba0ee360b8d69a35c7f2203ea8 (patch) | |
| tree | 17784192015e71464f1064af2b071c8cd7fe7f13 | |
| parent | 16fbdce62d9c89b794e303f4a232e4749b77e9ac (diff) | |
mm: fix division by 0 in percpu_pagelist_fraction()
percpu_pagelist_fraction_sysctl_handler() has only considered -EINVAL as
a possible error from proc_dointvec_minmax().
If any other error is returned, it would proceed to divide by zero since
percpu_pagelist_fraction wasn't getting initialized at any point. For
example, writing 0 bytes into the proc file would trigger the issue.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | mm/page_alloc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a712fb9e04ce..b21b3db15a7f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
| @@ -105,7 +105,7 @@ unsigned long totalreserve_pages __read_mostly; | |||
| 105 | */ | 105 | */ |
| 106 | unsigned long dirty_balance_reserve __read_mostly; | 106 | unsigned long dirty_balance_reserve __read_mostly; |
| 107 | 107 | ||
| 108 | int percpu_pagelist_fraction; | 108 | int percpu_pagelist_fraction = 8; |
| 109 | gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; | 109 | gfp_t gfp_allowed_mask __read_mostly = GFP_BOOT_MASK; |
| 110 | 110 | ||
| 111 | #ifdef CONFIG_PM_SLEEP | 111 | #ifdef CONFIG_PM_SLEEP |
| @@ -5203,7 +5203,7 @@ int percpu_pagelist_fraction_sysctl_handler(ctl_table *table, int write, | |||
| 5203 | int ret; | 5203 | int ret; |
| 5204 | 5204 | ||
| 5205 | ret = proc_dointvec_minmax(table, write, buffer, length, ppos); | 5205 | ret = proc_dointvec_minmax(table, write, buffer, length, ppos); |
| 5206 | if (!write || (ret == -EINVAL)) | 5206 | if (!write || (ret < 0)) |
| 5207 | return ret; | 5207 | return ret; |
| 5208 | for_each_populated_zone(zone) { | 5208 | for_each_populated_zone(zone) { |
| 5209 | for_each_possible_cpu(cpu) { | 5209 | for_each_possible_cpu(cpu) { |
