Messages in this thread | | | Date | Mon, 23 May 2022 00:04:43 +0100 | From | Matthew Wilcox <> | Subject | Re: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts |
| |
On Sun, May 22, 2022 at 03:08:42PM +0300, Vasily Averin wrote: > diff --git a/fs/proc/base.c b/fs/proc/base.c > index c1031843cc6a..4e4edf9db5f0 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -2237,13 +2237,13 @@ static struct dentry * > proc_map_files_instantiate(struct dentry *dentry, > struct task_struct *task, const void *ptr) > { > - fmode_t mode = (fmode_t)(unsigned long)ptr; > + const fmode_t *mode = ptr;
Why not ...
fmode_t mode = *(fmode_t *)ptr;
and then you don't need
> - ((mode & FMODE_READ ) ? S_IRUSR : 0) | > - ((mode & FMODE_WRITE) ? S_IWUSR : 0)); > + ((*mode & FMODE_READ ) ? S_IRUSR : 0) | > + ((*mode & FMODE_WRITE) ? S_IWUSR : 0));
| |