Skip to content

Commit

Permalink
Compile fixes for kernel >= 5.8
Browse files Browse the repository at this point in the history
With the commit 64fe66e8a95e in the Linux kernel, the member "mmap_sem" in the
struct mm_struct was renamed to "mmap_lock". This patch fixes the resulting
compile errors.
  • Loading branch information
choff committed Mar 8, 2021
1 parent 4af9d5d commit 443f984
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions binder/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#include <linux/slab.h>
#include <linux/pid_namespace.h>
#include <linux/security.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
#include <linux/mmap_lock.h>
#endif

#ifdef CONFIG_ANDROID_BINDER_IPC_32BIT
#define BINDER_IPC_32BIT 1
Expand Down Expand Up @@ -630,7 +633,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
mm = get_task_mm(proc->tsk);

if (mm) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
mmap_write_lock(mm);
#else
down_write(&mm->mmap_sem);
#endif
vma = proc->vma;
if (vma && mm != proc->vma_vm_mm) {
pr_err("%d: vma mm and task mm mismatch\n",
Expand Down Expand Up @@ -680,7 +687,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
/* vm_insert_page does not seem to increment the refcount */
}
if (mm) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
mmap_write_unlock(mm);
#else
up_write(&mm->mmap_sem);
#endif
mmput(mm);
}
return 0;
Expand All @@ -707,7 +718,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
}
err_no_vma:
if (mm) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
mmap_write_unlock(mm);
#else
up_write(&mm->mmap_sem);
#endif
mmput(mm);
}
return -ENOMEM;
Expand Down

0 comments on commit 443f984

Please sign in to comment.