linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hugetlbfs: fix protential null pointer dereference
@ 2019-04-11  3:53 Yufen Yu
  2019-04-11  8:19 ` Michal Hocko
  0 siblings, 1 reply; 7+ messages in thread
From: Yufen Yu @ 2019-04-11  3:53 UTC (permalink / raw)
  To: mike.kravetz, linux-mm; +Cc: kirill.shutemov, n-horiguchi, mhocko, yuyufen

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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-15 10:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-11  3:53 [PATCH v2] hugetlbfs: fix protential null pointer dereference Yufen Yu
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).