diff options
author | jie@chenjie6@huwei.com <jie@chenjie6@huwei.com> | 2018-08-11 03:23:06 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-05 10:18:36 +0300 |
commit | fbee7b5b8c28ed02b6d6603eef27730c148a4481 (patch) | |
tree | 527a216048894e251365af98e4f82dc295ebc41a /mm | |
parent | 8bbbd3a9a0f8ea4b22150639a05d03000b72fe12 (diff) | |
download | linux-fbee7b5b8c28ed02b6d6603eef27730c148a4481.tar.xz |
mm/memory.c: check return value of ioremap_prot
[ Upstream commit 24eee1e4c47977bdfb71d6f15f6011e7b6188d04 ]
ioremap_prot() can return NULL which could lead to an oops.
Link: http://lkml.kernel.org/r/1533195441-58594-1-git-send-email-chenjie6@huawei.com
Signed-off-by: chen jie <chenjie6@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: chenjie <chenjie6@huawei.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memory.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c index d5bb1465d30c..42db644f5ec4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3701,6 +3701,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 |