Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 94041
b: refs/heads/master
c: 2291990
h: refs/heads/master
i:
  94039: 46da9c6
v: v3
  • Loading branch information
Lee Schermerhorn authored and Linus Torvalds committed Apr 28, 2008
1 parent 516b628 commit 1fcfb74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fc36b8d3d819047eb4d23ca079fb4d3af20ff076
refs/heads/master: 2291990ab36b4b2d8a81b1f92e7a046e51632a60
17 changes: 11 additions & 6 deletions trunk/mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,11 @@ static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
unsigned short mode;
unsigned short flags = pol ? pol->flags : 0;

/*
* Sanity check: room for longest mode, flag and some nodes
*/
VM_BUG_ON(maxlen < strlen("interleave") + strlen("relative") + 16);

if (!pol || pol == &default_policy)
mode = MPOL_DEFAULT;
else
Expand All @@ -1991,7 +1996,6 @@ static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)

default:
BUG();
return -EFAULT;
}

l = strlen(policy_types[mode]);
Expand All @@ -2002,16 +2006,17 @@ static inline int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol)
p += l;

if (flags & MPOL_MODE_FLAGS) {
int need_bar = 0;

if (buffer + maxlen < p + 2)
return -ENOSPC;
*p++ = '=';

/*
* Currently, the only defined flags are mutually exclusive
*/
if (flags & MPOL_F_STATIC_NODES)
p += sprintf(p, "%sstatic", need_bar++ ? "|" : "");
if (flags & MPOL_F_RELATIVE_NODES)
p += sprintf(p, "%srelative", need_bar++ ? "|" : "");
p += snprintf(p, buffer + maxlen - p, "static");
else if (flags & MPOL_F_RELATIVE_NODES)
p += snprintf(p, buffer + maxlen - p, "relative");
}

if (!nodes_empty(nodes)) {
Expand Down

0 comments on commit 1fcfb74

Please sign in to comment.