Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51a79371 authored by Sunil Khatri's avatar Sunil Khatri
Browse files

msm: kgsl: Use vma_area_struct with proper locks



Make sure to use proper locks when using the
vma_struct_area. This will avoid the race condition
in a scenario where one thread gets a vma_struct_area
and other thread is unmapping it vma from the process.

Change-Id: I6c7837d1a8dd24fc6955ab5be8b1917a42f2cb53
Signed-off-by: default avatarSunil Khatri <sunilkh@codeaurora.org>
parent 7eb12688
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2225,21 +2225,23 @@ static int kgsl_setup_dmabuf_useraddr(struct kgsl_device *device,
		if (fd != 0)
			dmabuf = dma_buf_get(fd - 1);
	}
	up_read(&current->mm->mmap_sem);

	if (IS_ERR_OR_NULL(dmabuf))
	if (IS_ERR_OR_NULL(dmabuf)) {
		up_read(&current->mm->mmap_sem);
		return dmabuf ? PTR_ERR(dmabuf) : -ENODEV;
	}

	ret = kgsl_setup_dma_buf(device, pagetable, entry, dmabuf);
	if (ret) {
		dma_buf_put(dmabuf);
		up_read(&current->mm->mmap_sem);
		return ret;
	}

	/* Setup the user addr/cache mode for cache operations */
	entry->memdesc.useraddr = hostptr;
	_setup_cache_mode(entry, vma);

	up_read(&current->mm->mmap_sem);
	return 0;
}
#else