mirror of https://github.com/torvalds/linux.git
erofs: use credential guards
Use credential guards for scoped credential override with automatic restoration on scope exit. Link: https://patch.msgid.link/20251103-work-creds-guards-simple-v1-9-a3e156839e7f@kernel.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
ff2044cd27
commit
5e88d1aadc
|
|
@ -47,7 +47,6 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
|
|||
|
||||
static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
|
||||
{
|
||||
const struct cred *old_cred;
|
||||
struct iov_iter iter;
|
||||
int ret;
|
||||
|
||||
|
|
@ -61,9 +60,8 @@ static void erofs_fileio_rq_submit(struct erofs_fileio_rq *rq)
|
|||
rq->iocb.ki_flags = IOCB_DIRECT;
|
||||
iov_iter_bvec(&iter, ITER_DEST, rq->bvecs, rq->bio.bi_vcnt,
|
||||
rq->bio.bi_iter.bi_size);
|
||||
old_cred = override_creds(rq->iocb.ki_filp->f_cred);
|
||||
scoped_with_creds(rq->iocb.ki_filp->f_cred)
|
||||
ret = vfs_iocb_iter_read(rq->iocb.ki_filp, &rq->iocb, &iter);
|
||||
revert_creds(old_cred);
|
||||
if (ret != -EIOCBQUEUED)
|
||||
erofs_fileio_ki_complete(&rq->iocb, ret);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue