Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: <chenjie6@huawei.com>
To: linux-mm@kvack.org, tj@kernel.org
Cc: akpm@linux-foundation.org, lizefan@huawei.com,
	chen jie <"chen jie@chenjie6"@huwei.com>,
	chen jie <chenjie6@huawei.com>
Subject: [PATCH] mm:bugfix check return value of ioremap_prot
Date: Thu, 2 Aug 2018 07:37:21 +0000
Message-ID: <1533195441-58594-1-git-send-email-chenjie6@huawei.com> (raw)

From: chen jie <chen jie@chenjie6@huwei.com>

	ioremap_prot can return NULL which could lead to an oops

Signed-off-by: chen jie <chenjie6@huawei.com>
---
 mm/memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 7206a63..316c42e 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4397,6 +4397,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
-- 
1.8.3.4

             reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02  7:37 chenjie6 [this message]
2018-08-02 16:47 ` Yang Shi
2018-08-02 21:02   ` Andrew Morton
2018-08-03 12:47     ` Alexey Dobriyan
2018-08-03 23:05       ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1533195441-58594-1-git-send-email-chenjie6@huawei.com \
    --to=chenjie6@huawei.com \
    --cc="chen jie@chenjie6"@huwei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan@huawei.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git