From: Jens Axboe Date: Tue, 1 Jun 2010 10:42:12 +0000 (+0200) Subject: Merge branch 'master' into for-linus X-Git-Tag: upstream/snapshot3+hdmi~14040^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4ca761577535b2b4d153689ee97342797dfff05;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git Merge branch 'master' into for-linus Conflicts: fs/pipe.c Signed-off-by: Jens Axboe --- b4ca761577535b2b4d153689ee97342797dfff05 diff --cc fs/pipe.c index bdd3f96,db6eaab..541d662 --- a/fs/pipe.c +++ b/fs/pipe.c @@@ -1162,30 -1174,23 +1168,34 @@@ long pipe_fcntl(struct file *file, unsi mutex_lock(&pipe->inode->i_mutex); switch (cmd) { - case F_SETPIPE_SZ: - if (!capable(CAP_SYS_ADMIN) && arg > pipe_max_pages) { - ret = -EINVAL; + case F_SETPIPE_SZ: { + unsigned long nr_pages; + + /* + * Currently the array must be a power-of-2 size, so adjust + * upwards if needed. + */ + nr_pages = (arg + PAGE_SIZE - 1) >> PAGE_SHIFT; + nr_pages = roundup_pow_of_two(nr_pages); + - if (!capable(CAP_SYS_ADMIN) && nr_pages > pipe_max_pages) - return -EPERM; ++ if (!capable(CAP_SYS_ADMIN) && nr_pages > pipe_max_pages) { ++ ret = -EPERM; + goto out; + } + /* * The pipe needs to be at least 2 pages large to * guarantee POSIX behaviour. */ - if (nr_pages < 2) - return -EINVAL; - ret = pipe_set_size(pipe, nr_pages); + if (arg < 2) { + ret = -EINVAL; + goto out; + } + ret = pipe_set_size(pipe, arg); break; + } case F_GETPIPE_SZ: - ret = pipe->buffers; + ret = pipe->buffers * PAGE_SIZE; break; default: ret = -EINVAL;