diff options
-rw-r--r-- | mm/hugetlb.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 363c4d22602a..ce8e5bb6f031 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -1363,6 +1363,7 @@ static ssize_t nr_hugepages_show_common(struct kobject *kobj, | |||
1363 | 1363 | ||
1364 | return sprintf(buf, "%lu\n", nr_huge_pages); | 1364 | return sprintf(buf, "%lu\n", nr_huge_pages); |
1365 | } | 1365 | } |
1366 | |||
1366 | static ssize_t nr_hugepages_store_common(bool obey_mempolicy, | 1367 | static ssize_t nr_hugepages_store_common(bool obey_mempolicy, |
1367 | struct kobject *kobj, struct kobj_attribute *attr, | 1368 | struct kobject *kobj, struct kobj_attribute *attr, |
1368 | const char *buf, size_t len) | 1369 | const char *buf, size_t len) |
@@ -1375,11 +1376,16 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy, | |||
1375 | 1376 | ||
1376 | err = strict_strtoul(buf, 10, &count); | 1377 | err = strict_strtoul(buf, 10, &count); |
1377 | if (err) { | 1378 | if (err) { |
1378 | NODEMASK_FREE(nodes_allowed); | 1379 | err = 0; /* This seems wrong */ |
1379 | return 0; | 1380 | goto out; |
1380 | } | 1381 | } |
1381 | 1382 | ||
1382 | h = kobj_to_hstate(kobj, &nid); | 1383 | h = kobj_to_hstate(kobj, &nid); |
1384 | if (h->order >= MAX_ORDER) { | ||
1385 | err = -EINVAL; | ||
1386 | goto out; | ||
1387 | } | ||
1388 | |||
1383 | if (nid == NUMA_NO_NODE) { | 1389 | if (nid == NUMA_NO_NODE) { |
1384 | /* | 1390 | /* |
1385 | * global hstate attribute | 1391 | * global hstate attribute |
@@ -1405,6 +1411,9 @@ static ssize_t nr_hugepages_store_common(bool obey_mempolicy, | |||
1405 | NODEMASK_FREE(nodes_allowed); | 1411 | NODEMASK_FREE(nodes_allowed); |
1406 | 1412 | ||
1407 | return len; | 1413 | return len; |
1414 | out: | ||
1415 | NODEMASK_FREE(nodes_allowed); | ||
1416 | return err; | ||
1408 | } | 1417 | } |
1409 | 1418 | ||
1410 | static ssize_t nr_hugepages_show(struct kobject *kobj, | 1419 | static ssize_t nr_hugepages_show(struct kobject *kobj, |
@@ -1447,6 +1456,7 @@ static ssize_t nr_overcommit_hugepages_show(struct kobject *kobj, | |||
1447 | struct hstate *h = kobj_to_hstate(kobj, NULL); | 1456 | struct hstate *h = kobj_to_hstate(kobj, NULL); |
1448 | return sprintf(buf, "%lu\n", h->nr_overcommit_huge_pages); | 1457 | return sprintf(buf, "%lu\n", h->nr_overcommit_huge_pages); |
1449 | } | 1458 | } |
1459 | |||
1450 | static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj, | 1460 | static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj, |
1451 | struct kobj_attribute *attr, const char *buf, size_t count) | 1461 | struct kobj_attribute *attr, const char *buf, size_t count) |
1452 | { | 1462 | { |
@@ -1454,6 +1464,9 @@ static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj, | |||
1454 | unsigned long input; | 1464 | unsigned long input; |
1455 | struct hstate *h = kobj_to_hstate(kobj, NULL); | 1465 | struct hstate *h = kobj_to_hstate(kobj, NULL); |
1456 | 1466 | ||
1467 | if (h->order >= MAX_ORDER) | ||
1468 | return -EINVAL; | ||
1469 | |||
1457 | err = strict_strtoul(buf, 10, &input); | 1470 | err = strict_strtoul(buf, 10, &input); |
1458 | if (err) | 1471 | if (err) |
1459 | return 0; | 1472 | return 0; |
@@ -1864,6 +1877,9 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy, | |||
1864 | if (!write) | 1877 | if (!write) |
1865 | tmp = h->max_huge_pages; | 1878 | tmp = h->max_huge_pages; |
1866 | 1879 | ||
1880 | if (write && h->order >= MAX_ORDER) | ||
1881 | return -EINVAL; | ||
1882 | |||
1867 | table->data = &tmp; | 1883 | table->data = &tmp; |
1868 | table->maxlen = sizeof(unsigned long); | 1884 | table->maxlen = sizeof(unsigned long); |
1869 | ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); | 1885 | ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); |
@@ -1927,6 +1943,9 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, | |||
1927 | if (!write) | 1943 | if (!write) |
1928 | tmp = h->nr_overcommit_huge_pages; | 1944 | tmp = h->nr_overcommit_huge_pages; |
1929 | 1945 | ||
1946 | if (write && h->order >= MAX_ORDER) | ||
1947 | return -EINVAL; | ||
1948 | |||
1930 | table->data = &tmp; | 1949 | table->data = &tmp; |
1931 | table->maxlen = sizeof(unsigned long); | 1950 | table->maxlen = sizeof(unsigned long); |
1932 | ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); | 1951 | ret = proc_doulongvec_minmax(table, write, buffer, length, ppos); |