mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
smb: avoid pointless cred reference count bump
The creds are allocated via prepare_kernel_cred() which has already taken a reference. This also removes a pointless check that gives the impression that override_creds() can ever be called on a task with current->cred NULL. That's not possible afaict. Remove the check to not imply that there can be a dangling pointer in current->cred. Link: https://lore.kernel.org/r/20241125-work-cred-v2-21-68b9d38bb5b2@kernel.org Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
2b315eda9e
commit
62e5396c50
@ -780,11 +780,7 @@ int __ksmbd_override_fsids(struct ksmbd_work *work,
|
||||
cred->cap_effective = cap_drop_fs_set(cred->cap_effective);
|
||||
|
||||
WARN_ON(work->saved_cred);
|
||||
work->saved_cred = override_creds(get_new_cred(cred));
|
||||
if (!work->saved_cred) {
|
||||
abort_creds(cred);
|
||||
return -EINVAL;
|
||||
}
|
||||
work->saved_cred = override_creds(cred);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -796,13 +792,11 @@ int ksmbd_override_fsids(struct ksmbd_work *work)
|
||||
void ksmbd_revert_fsids(struct ksmbd_work *work)
|
||||
{
|
||||
const struct cred *cred;
|
||||
|
||||
WARN_ON(!work->saved_cred);
|
||||
|
||||
cred = current_cred();
|
||||
put_cred(revert_creds(work->saved_cred));
|
||||
put_cred(cred);
|
||||
cred = revert_creds(work->saved_cred);
|
||||
work->saved_cred = NULL;
|
||||
put_cred(cred);
|
||||
}
|
||||
|
||||
__le32 smb_map_generic_desired_access(__le32 daccess)
|
||||
|
Loading…
Reference in New Issue
Block a user