diff options
-rw-r--r-- | mm/mempolicy.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 155bb284dbf1..6b751565eed1 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -1951,7 +1951,7 @@ void numa_default_policy(void) | |||
1951 | 1951 | ||
1952 | /* | 1952 | /* |
1953 | * "local" is pseudo-policy: MPOL_PREFERRED with MPOL_F_LOCAL flag | 1953 | * "local" is pseudo-policy: MPOL_PREFERRED with MPOL_F_LOCAL flag |
1954 | * Used only for mpol_to_str() | 1954 | * Used only for mpol_parse_str() and mpol_to_str() |
1955 | */ | 1955 | */ |
1956 | #define MPOL_LOCAL (MPOL_INTERLEAVE + 1) | 1956 | #define MPOL_LOCAL (MPOL_INTERLEAVE + 1) |
1957 | static const char * const policy_types[] = | 1957 | static const char * const policy_types[] = |
@@ -1990,21 +1990,16 @@ int mpol_parse_str(char *str, unsigned short *mode, unsigned short *mode_flags, | |||
1990 | if (flags) | 1990 | if (flags) |
1991 | *flags++ = '\0'; /* terminate mode string */ | 1991 | *flags++ = '\0'; /* terminate mode string */ |
1992 | 1992 | ||
1993 | for (i = 0; i < MPOL_MAX; i++) { | 1993 | for (i = 0; i <= MPOL_LOCAL; i++) { |
1994 | if (!strcmp(str, policy_types[i])) { | 1994 | if (!strcmp(str, policy_types[i])) { |
1995 | *mode = i; | 1995 | *mode = i; |
1996 | break; | 1996 | break; |
1997 | } | 1997 | } |
1998 | } | 1998 | } |
1999 | if (i == MPOL_MAX) | 1999 | if (i > MPOL_LOCAL) |
2000 | goto out; | 2000 | goto out; |
2001 | 2001 | ||
2002 | switch (*mode) { | 2002 | switch (*mode) { |
2003 | case MPOL_DEFAULT: | ||
2004 | /* Don't allow a nodelist nor flags */ | ||
2005 | if (!nodelist && !flags) | ||
2006 | err = 0; | ||
2007 | break; | ||
2008 | case MPOL_PREFERRED: | 2003 | case MPOL_PREFERRED: |
2009 | /* Insist on a nodelist of one node only */ | 2004 | /* Insist on a nodelist of one node only */ |
2010 | if (nodelist) { | 2005 | if (nodelist) { |
@@ -2027,6 +2022,20 @@ int mpol_parse_str(char *str, unsigned short *mode, unsigned short *mode_flags, | |||
2027 | if (!nodelist) | 2022 | if (!nodelist) |
2028 | *policy_nodes = node_states[N_HIGH_MEMORY]; | 2023 | *policy_nodes = node_states[N_HIGH_MEMORY]; |
2029 | err = 0; | 2024 | err = 0; |
2025 | break; | ||
2026 | default: | ||
2027 | /* | ||
2028 | * MPOL_DEFAULT or MPOL_LOCAL | ||
2029 | * Don't allow a nodelist nor flags | ||
2030 | */ | ||
2031 | if (!nodelist && !flags) | ||
2032 | err = 0; | ||
2033 | if (*mode == MPOL_DEFAULT) | ||
2034 | goto out; | ||
2035 | /* else MPOL_LOCAL */ | ||
2036 | *mode = MPOL_PREFERRED; | ||
2037 | nodes_clear(*policy_nodes); | ||
2038 | break; | ||
2030 | } | 2039 | } |
2031 | 2040 | ||
2032 | *mode_flags = 0; | 2041 | *mode_flags = 0; |