Merge tag 'media/v5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[platform/kernel/linux-starfive.git] / kernel / cred.c
index c73a87a..f9a0ce6 100644 (file)
@@ -170,6 +170,11 @@ void exit_creds(struct task_struct *tsk)
        validate_creds(cred);
        alter_cred_subscribers(cred, -1);
        put_cred(cred);
+
+#ifdef CONFIG_KEYS_REQUEST_CACHE
+       key_put(current->cached_requested_key);
+       current->cached_requested_key = NULL;
+#endif
 }
 
 /**
@@ -323,6 +328,10 @@ int copy_creds(struct task_struct *p, unsigned long clone_flags)
        struct cred *new;
        int ret;
 
+#ifdef CONFIG_KEYS_REQUEST_CACHE
+       p->cached_requested_key = NULL;
+#endif
+
        if (
 #ifdef CONFIG_KEYS
                !p->cred->thread_keyring &&
@@ -460,9 +469,9 @@ int commit_creds(struct cred *new)
 
        /* alter the thread keyring */
        if (!uid_eq(new->fsuid, old->fsuid))
-               key_fsuid_changed(task);
+               key_fsuid_changed(new);
        if (!gid_eq(new->fsgid, old->fsgid))
-               key_fsgid_changed(task);
+               key_fsgid_changed(new);
 
        /* do it
         * RLIMIT_NPROC limits on user->processes have already been checked