From: Yufen Yu <yuyufen@huawei.com>
To: <mike.kravetz@oracle.com>, <linux-mm@kvack.org>
Cc: <kirill.shutemov@linux.intel.com>, <n-horiguchi@ah.jp.nec.com>,
<mhocko@kernel.org>, <yuyufen@huawei.com>
Subject: [PATCH v2] hugetlbfs: fix protential null pointer dereference
Date: Thu, 11 Apr 2019 11:53:18 +0800 [thread overview]
Message-ID: <20190411035318.32976-1-yuyufen@huawei.com> (raw)
This patch can avoid protential null pointer dereference for resv_map.
As Mike Kravetz say:
Even if we can not hit this condition today, I still believe it
would be a good idea to make this type of change. It would
prevent a possible NULL dereference in case the structure of code
changes in the future.
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Michal Hocko <mhocko@kernel.org>
Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
mm/hugetlb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 97b1e0290c66..fe74f94e5327 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4465,6 +4465,8 @@ int hugetlb_reserve_pages(struct inode *inode,
*/
if (!vma || vma->vm_flags & VM_MAYSHARE) {
resv_map = inode_resv_map(inode);
+ if (!resv_map)
+ return -EACCES;
chg = region_chg(resv_map, from, to);
--
2.16.2.dirty
next reply other threads:[~2019-04-11 3:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-11 3:53 Yufen Yu [this message]
2019-04-11 8:19 ` Michal Hocko
2019-04-11 16:52 ` Mike Kravetz
2019-04-11 18:22 ` Michal Hocko
2019-04-11 18:40 ` Mike Kravetz
2019-04-11 18:49 ` Michal Hocko
2019-04-15 10:26 ` William Kucharski
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=20190411035318.32976-1-yuyufen@huawei.com \
--to=yuyufen@huawei.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=n-horiguchi@ah.jp.nec.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox