From patchwork Thu Oct 17 10:38:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 11195397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21B2D14DB for ; Thu, 17 Oct 2019 10:39:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C8F7F21835 for ; Thu, 17 Oct 2019 10:39:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="SGqri2vB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8F7F21835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mykernel.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8BB208E0005; Thu, 17 Oct 2019 06:39:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 845098E0003; Thu, 17 Oct 2019 06:39:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E49B8E0005; Thu, 17 Oct 2019 06:39:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 463948E0003 for ; Thu, 17 Oct 2019 06:39:08 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 99DBB585F for ; Thu, 17 Oct 2019 10:39:07 +0000 (UTC) X-FDA: 76052929134.01.smash86_6c96a5f65472a X-Spam-Summary: 2,0,0,29fa263ac9f279c1,d41d8cd98f00b204,cgxu519@mykernel.net,:mike.kravetz@oracle.com::linux-kernel@vger.kernel.org:cgxu519@mykernel.net,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1437:1513:1515:1516:1518:1521:1534:1540:1593:1594:1711:1730:1747:1777:1792:2198:2199:2380:2393:2559:2562:2731:3138:3139:3140:3141:3142:3352:3867:3870:4250:4321:5007:6119:6261:6653:10004:10400:11026:11658:11914:12297:12555:12895:12986:13019:13069:13311:13357:14181:14394:14721:21080:21444:21451:21627:30054,0,RBL:163.53.93.247:@mykernel.net:.lbl8.mailshell.net-62.14.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:263,LUA_SUMMARY:none X-HE-Tag: smash86_6c96a5f65472a X-Filterd-Recvd-Size: 3179 Received: from sender2-of-o52.zoho.com.cn (sender2-of-o52.zoho.com.cn [163.53.93.247]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Oct 2019 10:39:05 +0000 (UTC) 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 X-ZohoCNMailClient: External X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reported-by: Chengguang Xu Signed-off-by: Mike Kravetz Reported-by: Chengguang Xu Signed-off-by: Mike Kravetz --- 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++;