/* install a process keyring directly to a credentials struct */
int install_process_keyring_to_cred(struct cred *new)
/* install a process keyring directly to a credentials struct */
int install_process_keyring_to_cred(struct cred *new)
{
	struct key *keyring;
	int ret;
	if (new->tgcred->process_keyring)
		return -EEXIST;
	keyring = keyring_alloc("_pid", new->uid, new->gid,
				new, KEY_ALLOC_QUOTA_OVERRUN, NULL);
	if (IS_ERR(keyring))
		return PTR_ERR(keyring);
	spin_lock_irq(&new->tgcred->lock);
	if (!new->tgcred->process_keyring) {
		new->tgcred->process_keyring = keyring;
		keyring = NULL;
		ret = 0;
	} else {
		ret = -EEXIST;
	}
	spin_unlock_irq(&new->tgcred->lock);
	key_put(keyring);
	return ret;
}