Skip to content

Commit

Permalink
Revert "mm: mmap: fix fput in error path v2"
Browse files Browse the repository at this point in the history
The kernel test robot is not happy with that.

This reverts commit 0227da0.

Signed-off-by: Christian König <christian.koenig@amd.com>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/394772/
  • Loading branch information
ChristianKoenigAMD committed Nov 5, 2020
1 parent e40b0b5 commit 2c16d29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions drivers/dma-buf/dma-buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,9 @@ EXPORT_SYMBOL_GPL(dma_buf_end_cpu_access);
int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
unsigned long pgoff)
{
struct file *oldfile;
int ret;

if (WARN_ON(!dmabuf || !vma))
return -EINVAL;

Expand All @@ -1183,11 +1186,22 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
return -EINVAL;

/* readjust the vma */
fput(vma->vm_file);
vma->vm_file = get_file(dmabuf->file);
get_file(dmabuf->file);
oldfile = vma->vm_file;
vma->vm_file = dmabuf->file;
vma->vm_pgoff = pgoff;

return dmabuf->ops->mmap(dmabuf, vma);
ret = dmabuf->ops->mmap(dmabuf, vma);
if (ret) {
/* restore old parameters on failure */
vma->vm_file = oldfile;
fput(dmabuf->file);
} else {
if (oldfile)
fput(oldfile);
}
return ret;

}
EXPORT_SYMBOL_GPL(dma_buf_mmap);

Expand Down
2 changes: 1 addition & 1 deletion mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1899,8 +1899,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
return addr;

unmap_and_free_vma:
fput(vma->vm_file);
vma->vm_file = NULL;
fput(file);

/* Undo any partial mapping done by a device driver. */
unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
Expand Down

0 comments on commit 2c16d29

Please sign in to comment.