Skip to content

Commit

Permalink
mm/memory.c: check return value of ioremap_prot
Browse files Browse the repository at this point in the history
[ Upstream commit 24eee1e ]

ioremap_prot() can return NULL which could lead to an oops.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: chen jie <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Li Zefan <[email protected]>
Cc: chenjie <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Alexey Dobriyan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jie@[email protected] authored and gregkh committed Sep 5, 2018
1 parent f3ab050 commit 4c41a07
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -3522,6 +3522,9 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
return -EINVAL;

maddr = ioremap_prot(phys_addr, PAGE_ALIGN(len + offset), prot);
if (!maddr)
return -ENOMEM;

if (write)
memcpy_toio(maddr + offset, buf, len);
else
Expand Down

0 comments on commit 4c41a07

Please sign in to comment.