Skip to content

Commit 597425d

Browse files
Hugh Dickinsakpm00
authored andcommitted
mm: userfaultfd: add new UFFDIO_POISON ioctl: fix
Smatch has observed that pte_offset_map_lock() is now allowed to fail, and then ptl should not be unlocked. Use -EAGAIN here like elsewhere. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Axel Rasmussen <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Peter Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent fc71884 commit 597425d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mm/userfaultfd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ static int mfill_atomic_pte_poison(pmd_t *dst_pmd,
300300
spinlock_t *ptl;
301301

302302
_dst_pte = make_pte_marker(PTE_MARKER_POISONED);
303+
ret = -EAGAIN;
303304
dst_pte = pte_offset_map_lock(dst_mm, dst_pmd, dst_addr, &ptl);
305+
if (!dst_pte)
306+
goto out;
304307

305308
if (mfill_file_over_size(dst_vma, dst_addr)) {
306309
ret = -EFAULT;
@@ -319,6 +322,7 @@ static int mfill_atomic_pte_poison(pmd_t *dst_pmd,
319322
ret = 0;
320323
out_unlock:
321324
pte_unmap_unlock(dst_pte, ptl);
325+
out:
322326
return ret;
323327
}
324328

0 commit comments

Comments
 (0)