linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlbfs: fix error handling in init_hugetlbfs_fs()
@ 2019-10-17 10:38 Chengguang Xu
  2019-10-18  0:08 ` Mike Kravetz
  2019-10-28 21:27 ` Mike Kravetz
  0 siblings, 2 replies; 8+ messages in thread
From: Chengguang Xu @ 2019-10-17 10:38 UTC (permalink / raw)
  To: mike.kravetz; +Cc: linux-mm, linux-kernel, Chengguang Xu

In order to avoid using incorrect mnt, we should set
mnt to NULL when we get error from mount_one_hugetlbfs().

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/hugetlbfs/inode.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a478df035651..427d845e7706 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1470,9 +1470,12 @@ static int __init init_hugetlbfs_fs(void)
 	i = 0;
 	for_each_hstate(h) {
 		mnt = mount_one_hugetlbfs(h);
-		if (IS_ERR(mnt) && i == 0) {
-			error = PTR_ERR(mnt);
-			goto out;
+		if (IS_ERR(mnt)) {
+			if (i == 0) {
+				error = PTR_ERR(mnt);
+				goto out;
+			}
+			mnt = NULL;
 		}
 		hugetlbfs_vfsmount[i] = mnt;
 		i++;
-- 
2.20.1




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

end of thread, other threads:[~2019-10-29 22:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 10:38 [PATCH] hugetlbfs: fix error handling in init_hugetlbfs_fs() Chengguang Xu
2019-10-18  0:08 ` Mike Kravetz
2019-10-18  0:47   ` Mike Kravetz
2019-10-28 21:27 ` Mike Kravetz
2019-10-29  4:36   ` Chengguang Xu
2019-10-29 20:47     ` Mike Kravetz
2019-10-29 22:24       ` Andrew Morton
2019-10-29 22:36         ` Mike Kravetz

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).