Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp236777pxb; Wed, 18 Nov 2020 03:15:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPVTWTcEd2ZI+E+KEDikDrSp/GkhNDQ26+gZt151aO81bBh63MzhMUZO3RQjJ1l9pI9f8q X-Received: by 2002:a50:da46:: with SMTP id a6mr20956979edk.272.1605698131058; Wed, 18 Nov 2020 03:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605698131; cv=none; d=google.com; s=arc-20160816; b=gUhfHU1p1HnO4COMv9yry4T3B+OBVSTFFsdz8mwzoCXiDu/VV88WCxg8y8WZF14774 XMQe+XgUcQ5wP2IrhauFQWFfeazRSefk2LfyFBzmawoNVrXKxJHmxT7u05IgtqKtOHVy ANgh0FhVK0mZCdlEKvk0iOami2sZ0LiQKrCcptjiqrBZHH7NqLTqz5GKu5xuhM1oD8Ho QMD8EJhKZAqPCIL5owtymSC2vroll9IcSehW1+kfd25Uz83T+5LEDEhaCw7qTWpI8X1c 1aBD4Ry9r1TCYGHGQaF5CV3dorux4mNkkw0pyn8pijj2EIQioXspE0iVAdcbZ9eM7It8 mHWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nnkoQ4U2asw5qHFF2XJJ0JiHHUngq9z4STdpdhQrmb4=; b=pp5+pHocppnawFxivHGXsoglisD4ZOdqKaiYd0TFvKKMqWAdgaq/TLZDrI1FgLqKaJ 9SqTrGOLKZYrgBg6SAEUju/qhOvGs48J1kIM+zys5VY1+t5sYY9/WZSu7iL4wV1Lfp84 oy4NiJqjK1I7lt+XkooUGa/HUccstUbraADR3cBdlbwIsPes3aKIHsazWW+ePGy7hPEk Ru3XfP7iZB0pngzEHPD9Tc/Jk63tk6JOu/Z+EzTM+nRsRy9tzpiH+jxIpscZRoQm+5LA JnMK37VPLqyrYijp7+2xWFL7yN2DCRbRNjuzneA24lDMbKrMYDdVgX6JMNwCG3i8Ryl5 P9Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn8si9388267edb.455.2020.11.18.03.15.07; Wed, 18 Nov 2020 03:15:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgKRLMI (ORCPT + 99 others); Wed, 18 Nov 2020 06:12:08 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8108 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbgKRLMH (ORCPT ); Wed, 18 Nov 2020 06:12:07 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cbg9r6vQtzLq7D; Wed, 18 Nov 2020 19:11:44 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Wed, 18 Nov 2020 19:11:58 +0800 From: Yu Kuai To: , CC: , , , Subject: [PATCH] xfs: return corresponding errcode if xfs_initialize_perag() fail Date: Wed, 18 Nov 2020 19:15:31 +0800 Message-ID: <20201118111531.455814-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In xfs_initialize_perag(), if kmem_zalloc(), xfs_buf_hash_init(), or radix_tree_preload() failed, the returned value 'error' is not set accordingly. Fixes: commit 8b26c5825e02 ("xfs: handle ENOMEM correctly during initialisation of perag structures") Reported-by: Hulk Robot Signed-off-by: Yu Kuai --- fs/xfs/xfs_mount.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 150ee5cb8645..7110507a2b6b 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -194,20 +194,25 @@ xfs_initialize_perag( } pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL); - if (!pag) + if (!pag) { + error = -ENOMEM; goto out_unwind_new_pags; + } pag->pag_agno = index; pag->pag_mount = mp; spin_lock_init(&pag->pag_ici_lock); INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC); - if (xfs_buf_hash_init(pag)) + + error = xfs_buf_hash_init(pag); + if (error) goto out_free_pag; init_waitqueue_head(&pag->pagb_wait); spin_lock_init(&pag->pagb_lock); pag->pagb_count = 0; pag->pagb_tree = RB_ROOT; - if (radix_tree_preload(GFP_NOFS)) + error = radix_tree_preload(GFP_NOFS); + if (error) goto out_hash_destroy; spin_lock(&mp->m_perag_lock); -- 2.25.4