Commit e006043a authored by Jack Steiner's avatar Jack Steiner Committed by Linus Torvalds

gru: check for valid vma

Fix bug caused by failure to allocate a GRU gts structure.  The old code
failed to handle the case where the vma was invalid.
Signed-off-by: default avatarJack Steiner <steiner@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 33f36483
...@@ -90,19 +90,22 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr) ...@@ -90,19 +90,22 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)
{ {
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
struct vm_area_struct *vma; struct vm_area_struct *vma;
struct gru_thread_state *gts = NULL; struct gru_thread_state *gts = ERR_PTR(-EINVAL);
down_write(&mm->mmap_sem); down_write(&mm->mmap_sem);
vma = gru_find_vma(vaddr); vma = gru_find_vma(vaddr);
if (vma) if (!vma)
gts = gru_alloc_thread_state(vma, TSID(vaddr, vma)); goto err;
if (!IS_ERR(gts)) {
mutex_lock(&gts->ts_ctxlock); gts = gru_alloc_thread_state(vma, TSID(vaddr, vma));
downgrade_write(&mm->mmap_sem); if (IS_ERR(gts))
} else { goto err;
up_write(&mm->mmap_sem); mutex_lock(&gts->ts_ctxlock);
} downgrade_write(&mm->mmap_sem);
return gts;
err:
up_write(&mm->mmap_sem);
return gts; return gts;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment