aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mempolicy.h
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2013-11-12 18:07:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:05 -0500
commit948927ee9e4f35f287e61a79c9f0e85ca2202c7d (patch)
tree611c78ab8b15b7ed1bb1e03791711bfb8f19edf5 /include/linux/mempolicy.h
parent40c3baa7c66f1352521378ee83509fb8f4c465de (diff)
mm, mempolicy: make mpol_to_str robust and always succeed
mpol_to_str() should not fail. Currently, it either fails because the string buffer is too small or because a string hasn't been defined for a mempolicy mode. If a new mempolicy mode is introduced and no string is defined for it, just warn and return "unknown". If the buffer is too small, just truncate the string and return, the same behavior as snprintf(). This also fixes a bug where there was no NULL-byte termination when doing *p++ = '=' and *p++ ':' and maxlen has been reached. Signed-off-by: David Rientjes <rientjes@google.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Chen Gang <gang.chen@asianux.com> Cc: Rik van Riel <riel@redhat.com> Cc: Dave Jones <davej@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mempolicy.h')
-rw-r--r--include/linux/mempolicy.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index ea4d2495c646..9fe426b30a41 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -169,7 +169,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from,
169extern int mpol_parse_str(char *str, struct mempolicy **mpol); 169extern int mpol_parse_str(char *str, struct mempolicy **mpol);
170#endif 170#endif
171 171
172extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol); 172extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol);
173 173
174/* Check if a vma is migratable */ 174/* Check if a vma is migratable */
175static inline int vma_migratable(struct vm_area_struct *vma) 175static inline int vma_migratable(struct vm_area_struct *vma)
@@ -307,9 +307,8 @@ static inline int mpol_parse_str(char *str, struct mempolicy **mpol)
307} 307}
308#endif 308#endif
309 309
310static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) 310static inline void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
311{ 311{
312 return 0;
313} 312}
314 313
315static inline int mpol_misplaced(struct page *page, struct vm_area_struct *vma, 314static inline int mpol_misplaced(struct page *page, struct vm_area_struct *vma,