Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp868978ybg; Fri, 18 Oct 2019 08:33:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlUQNJg/WJdTLVykebRv3rAVb7ODKRTDgYdBimWGH6QKx4UtuV+rHVWsdH+B/qaJJp+6uK X-Received: by 2002:a05:6402:1686:: with SMTP id a6mr10286943edv.174.1571412822881; Fri, 18 Oct 2019 08:33:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1571412822; cv=pass; d=google.com; s=arc-20160816; b=LdWLB7Y+mGX2IgSwywSX02ppnDmUxsNfp3Q3/cbaKpo+Nt4JpNvRQGgBVwi/k364xY lyLcyGVZqUwyJPfBtrO/NhJtNloFGuHxYculKcZWu9Y4CaY9fcogsyp34btVnRj7cT3e 3mZXcFLlKzve0gKjK7YtC7DB1ZpvvVnGlXBJdcgJkJh2pbe92Pff/z2bUUblcNzpt2VE 2VwdAYtCqEXceDLsN4Xpl8mIjADlqlSAxcm2ZImKsiUNP8UhOFkc8/LKJqzZ9zWSIDKy pSLKEIbCtZewNFWdzbl0oDsSVK4+XEIcV9tICXXGyPf/BmyP7uQ3xHuKuTBiI8MROH6c SE4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :date:subject:message-id:cc:to:from:dkim-signature; bh=4Ck44gH3F5vkNVlOz4QQfajHuL8YMWxdkY+aDrIBl1I=; b=wcIRsuh6zCZEkiksRckzCNIF4xPfbwA6mjWyWWn7Vj24c2eHUEYT5Zq1+gcyBt5rDL Irp8oOkX3P2x7M2UPmArKV3DVi3QUk+gvHqwiBAAqxW34oKxFTR/bCY1fQq8aaCsCdvR PMMw7dZ6qZmP68GJ3g154KX/OZN3brjuie3dw/1KILQG1kRfy4Ww9/zaOgGYwelFsnKq x8gWINfI13mUkHEKopxfLCbPGFXv0bJrFtmPIxn59VxJQ3b2OtT7OrxiyF6FULGD55en v1bN/4JiFCmZUMNcEft9Q6XpXE5WVTyMSXsiVv3L2/7rInJrxjP8HaGiEFP3pZ7AZQL9 MLIg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=SGqri2vB; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si3772164edy.441.2019.10.18.08.33.18; Fri, 18 Oct 2019 08:33:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=SGqri2vB; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408892AbfJQKjZ (ORCPT + 99 others); Thu, 17 Oct 2019 06:39:25 -0400 Received: from sender2-of-o52.zoho.com.cn ([163.53.93.247]:21573 "EHLO sender2-of-o52.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408885AbfJQKjZ (ORCPT ); Thu, 17 Oct 2019 06:39:25 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1571308735; cv=none; d=zoho.com.cn; s=zohoarc; b=KMGjVJ9n2Jf3BbfCyzwyDcHqgZbNBBr3zMWlN2dD77p1OiKHc4qf2KNljoBw35dNGOICciLs/SE1kE5ZYL1TntwfjZ9FyVJPTcuGQ50y+17jhG1MacmQeSesE2qXxocHywpUIQ6QxbWbnxs8DHzyTx1IPLXEllXriol3gkT0+ZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1571308735; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To:ARC-Authentication-Results; bh=4Ck44gH3F5vkNVlOz4QQfajHuL8YMWxdkY+aDrIBl1I=; b=kKy/nUtZYwd5faTMgC9fttMXn7xhq/Tz/PGaZqVfqmOMdST02/kuSnMkZ2UD2p1QRURpLDhuHku6xkRMp7KuUt5BjoMVB0hIvJXiE0Smg0hzufbxNwFAqVRUWpjv2UkaBAMF/pv09Ux8QUuHnPHG82QSygotpSC4RCkjH4np37Y= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1571308735; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; l=893; bh=4Ck44gH3F5vkNVlOz4QQfajHuL8YMWxdkY+aDrIBl1I=; b=SGqri2vBkpqGdHo6O2bH/Ylu7wMNXC+ATNmKcUR+U/NVl5MjbloUb/xT74zp+AyY aafVe6Cxcl5CiDWG9pvpxcjZj/V6MU8Cffhd5xSRoZHdWibotYSdJsXYyYM0RVWbeCg 8QevtI4Fq6feQ8QwJc6xC1RdWLp9WwU491EZ910g= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1571308734172527.2831788423041; Thu, 17 Oct 2019 18:38:54 +0800 (CST) From: Chengguang Xu To: mike.kravetz@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20191017103822.8610-1-cgxu519@mykernel.net> Subject: [PATCH] hugetlbfs: fix error handling in init_hugetlbfs_fs() Date: Thu, 17 Oct 2019 18:38:22 +0800 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) =09i =3D 0; =09for_each_hstate(h) { =09=09mnt =3D mount_one_hugetlbfs(h); -=09=09if (IS_ERR(mnt) && i =3D=3D 0) { -=09=09=09error =3D PTR_ERR(mnt); -=09=09=09goto out; +=09=09if (IS_ERR(mnt)) { +=09=09=09if (i =3D=3D 0) { +=09=09=09=09error =3D PTR_ERR(mnt); +=09=09=09=09goto out; +=09=09=09} +=09=09=09mnt =3D NULL; =09=09} =09=09hugetlbfs_vfsmount[i] =3D mnt; =09=09i++; --=20 2.20.1