diff options
Diffstat (limited to 'drivers/misc/sgi-gru/grufault.c')
-rw-r--r-- | drivers/misc/sgi-gru/grufault.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c index ada7df7e0968..7466234450f3 100644 --- a/drivers/misc/sgi-gru/grufault.c +++ b/drivers/misc/sgi-gru/grufault.c | |||
@@ -90,19 +90,22 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr) | |||
90 | { | 90 | { |
91 | struct mm_struct *mm = current->mm; | 91 | struct mm_struct *mm = current->mm; |
92 | struct vm_area_struct *vma; | 92 | struct vm_area_struct *vma; |
93 | struct gru_thread_state *gts = NULL; | 93 | struct gru_thread_state *gts = ERR_PTR(-EINVAL); |
94 | 94 | ||
95 | down_write(&mm->mmap_sem); | 95 | down_write(&mm->mmap_sem); |
96 | vma = gru_find_vma(vaddr); | 96 | vma = gru_find_vma(vaddr); |
97 | if (vma) | 97 | if (!vma) |
98 | gts = gru_alloc_thread_state(vma, TSID(vaddr, vma)); | 98 | goto err; |
99 | if (!IS_ERR(gts)) { | 99 | |
100 | mutex_lock(>s->ts_ctxlock); | 100 | gts = gru_alloc_thread_state(vma, TSID(vaddr, vma)); |
101 | downgrade_write(&mm->mmap_sem); | 101 | if (IS_ERR(gts)) |
102 | } else { | 102 | goto err; |
103 | up_write(&mm->mmap_sem); | 103 | mutex_lock(>s->ts_ctxlock); |
104 | } | 104 | downgrade_write(&mm->mmap_sem); |
105 | return gts; | ||
105 | 106 | ||
107 | err: | ||
108 | up_write(&mm->mmap_sem); | ||
106 | return gts; | 109 | return gts; |
107 | } | 110 | } |
108 | 111 | ||