mm/memory.c: check return value of ioremap_prot
authorjie@[email protected] <jie@[email protected]>
Sat, 11 Aug 2018 00:23:06 +0000 (17:23 -0700)
committerLinus Torvalds <[email protected]>
Sat, 11 Aug 2018 03:19:58 +0000 (20:19 -0700)
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]>
mm/memory.c

index dab1511294add14ba1290ded1dcd65408e274a4c..c5e87a3a82ba340254ff66b446c9b853fc211dde 100644 (file)
@@ -4395,6 +4395,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