dma_buf_getfile(): don't bother with ->f_flags reassignments
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 20 Jun 2021 17:53:35 +0000 (13:53 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 17 Aug 2022 21:25:54 +0000 (17:25 -0400)
just pass the already sanitized value to alloc_file_pseudo().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/dma-buf/dma-buf.c

index efb4990b29e105c7df61b6267ebe9abdd4ba60ac..1b1c1c002b8df6e8e1b59345c46762a528abced2 100644 (file)
@@ -531,11 +531,11 @@ static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
         * value.
         */
        inode->i_ino = atomic64_add_return(1, &dmabuf_inode);
+       flags &= O_ACCMODE | O_NONBLOCK;
        file = alloc_file_pseudo(inode, dma_buf_mnt, "dmabuf",
                                 flags, &dma_buf_fops);
        if (IS_ERR(file))
                goto err_alloc_file;
-       file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
        file->private_data = dmabuf;
        file->f_path.dentry->d_fsdata = dmabuf;