cred: add missing return error code when set_cred_ucounts() failed
authorYang Yingliang <yangyingliang@huawei.com>
Wed, 26 May 2021 14:38:05 +0000 (22:38 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 15:07:52 +0000 (17:07 +0200)
commit 5e6b8a50a7cec5686ee2c4bda1d49899c79a7eae upstream.

If set_cred_ucounts() failed, we need return the error code.

Fixes: 905ae01c4ae2 ("Add a reference to ucounts for each cred")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lkml.kernel.org/r/20210526143805.2549649-1-yangyingliang@huawei.com
Reviewed-by: Alexey Gladkov <legion@kernel.org>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/cred.c

index 642d62f7b46dec8b4d486257841da95487ad3312..9c2759166bd82df528d7edf8d3228d0d30f971de 100644 (file)
@@ -372,7 +372,8 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
                ret = create_user_ns(new);
                if (ret < 0)
                        goto error_put;
-               if (set_cred_ucounts(new) < 0)
+               ret = set_cred_ucounts(new);
+               if (ret < 0)
                        goto error_put;
        }