Skip to content

Commit 970655a

Browse files
committed
xen/gntdev: fix gntdev_mmap() error exit path
Commit d3eeb1d ("xen/gntdev: use mmu_interval_notifier_insert") introduced an error in gntdev_mmap(): in case the call of mmu_interval_notifier_insert_locked() fails the exit path should not call mmu_interval_notifier_remove(), as this might result in NULL dereferences. One reason for failure is e.g. a signal pending for the running process. Fixes: d3eeb1d ("xen/gntdev: use mmu_interval_notifier_insert") Cc: [email protected] Reported-by: Marek Marczykowski-Górecki <[email protected]> Tested-by: Marek Marczykowski-Górecki <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Luca Fancellu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent 6efb943 commit 970655a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/xen/gntdev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,10 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
10171017
err = mmu_interval_notifier_insert_locked(
10181018
&map->notifier, vma->vm_mm, vma->vm_start,
10191019
vma->vm_end - vma->vm_start, &gntdev_mmu_ops);
1020-
if (err)
1020+
if (err) {
1021+
map->vma = NULL;
10211022
goto out_unlock_put;
1023+
}
10221024
}
10231025
mutex_unlock(&priv->lock);
10241026

0 commit comments

Comments
 (0)