mirror of
https://github.com/adulau/aha.git
synced 2024-12-26 18:56:14 +00:00
cgroup: fix strstrip() misuse
cgroup_write_X64() and cgroup_write_string() ignore the return value of strstrip(). it makes small inconsistent behavior. example: ========================= # cd /mnt/cgroup/hoge # cat memory.swappiness 60 # echo "59 " > memory.swappiness # cat memory.swappiness 59 # echo " 58" > memory.swappiness bash: echo: write error: Invalid argument This patch fixes it. Cc: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Paul Menage <menage@google.com> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
58355c7876
commit
478988d3b2
1 changed files with 3 additions and 5 deletions
|
@ -1710,14 +1710,13 @@ static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft,
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
buffer[nbytes] = 0; /* nul-terminate */
|
buffer[nbytes] = 0; /* nul-terminate */
|
||||||
strstrip(buffer);
|
|
||||||
if (cft->write_u64) {
|
if (cft->write_u64) {
|
||||||
u64 val = simple_strtoull(buffer, &end, 0);
|
u64 val = simple_strtoull(strstrip(buffer), &end, 0);
|
||||||
if (*end)
|
if (*end)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
retval = cft->write_u64(cgrp, cft, val);
|
retval = cft->write_u64(cgrp, cft, val);
|
||||||
} else {
|
} else {
|
||||||
s64 val = simple_strtoll(buffer, &end, 0);
|
s64 val = simple_strtoll(strstrip(buffer), &end, 0);
|
||||||
if (*end)
|
if (*end)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
retval = cft->write_s64(cgrp, cft, val);
|
retval = cft->write_s64(cgrp, cft, val);
|
||||||
|
@ -1753,8 +1752,7 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[nbytes] = 0; /* nul-terminate */
|
buffer[nbytes] = 0; /* nul-terminate */
|
||||||
strstrip(buffer);
|
retval = cft->write_string(cgrp, cft, strstrip(buffer));
|
||||||
retval = cft->write_string(cgrp, cft, buffer);
|
|
||||||
if (!retval)
|
if (!retval)
|
||||||
retval = nbytes;
|
retval = nbytes;
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Reference in a new issue