[PATCH] userns: fix return value in map_write

Gao feng gaofeng at cn.fujitsu.com
Wed Oct 10 03:57:55 UTC 2012


If the map is already set,we should return -EINVAL.

Signed-off-by: Gao feng <gaofeng at cn.fujitsu.com>
---
 kernel/user_namespace.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 054471d..0231f87 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -560,11 +560,11 @@ static ssize_t map_write(struct file *file, const char __user *buf,
 	 */
 	mutex_lock(&id_map_mutex);
 
-	ret = -EPERM;
 	/* Only allow one successful write to the map */
 	if (map->nr_extents != 0)
 		goto out;
 
+	ret = -EPERM;
 	/* Require the appropriate privilege CAP_SETUID or CAP_SETGID
 	 * over the user namespace in order to set the id mapping.
 	 */
-- 
1.7.7.6



More information about the Containers mailing list