Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1308097pxu; Mon, 23 Nov 2020 17:56:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdlI54w55M0nJCvPVy/qlYe5vEL2CuY2JpG1YVXAtsUvsSHz+49breHol+1WgeCnSOQlB3 X-Received: by 2002:a17:906:6d99:: with SMTP id h25mr2128919ejt.281.1606182964050; Mon, 23 Nov 2020 17:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606182964; cv=none; d=google.com; s=arc-20160816; b=uO7YlW9lZk5Bv2xSppsctqg9ctGXXpN+WTpvKP++Sm4HY5CROM9WFidbunyIOEIxJF 8V4nZE5u1Ziu+oswAJbDRmh7YXA6Mv6RpDEJ1n61WvhvIVY454IS9YtZw0Kw4XDP9Jdj Ed3FN66mWjsh4NUsDeeT17mWxlBbLh8ejQB4jj1+0KxivqfL4EbWZg4UJ97E4YW99Tgr WjXV8REhTOd3tz0MLtQwjZ9WDWbGwHNuSQVo8Ixpndk5U8khRA/nrqKGRRtl8kNeG/Ip S58ID3MkIpUq4Bvg9KsFU0h74//1vCGJZBV8wlqPu3cptHwgx2HHAymLKysslbIfsxBj Zr6w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G51W1K2ZGdo6lENV573ppokOmK6iTjpnbM4429Q9cIQ=; b=ypJIEnk62YbrDT/JtaEOXA2gbauZHgoJmugLG3QFTvwQHjFa2J2lYPdFWZ5LoEkQcH Nce6Z2frX6ZcGyw4EzkNd0vOrw15GfLYH5T0kCKwACIrkHtx6VP50Lcz0bTO/s1W//oZ 1Z4IVdNv6/oJpxFxOEtkNcRfFe7GxlZapL3ugIx20TSuQGIrmvUO4C9ayygKZt/M6uaR yq35keFKbN9/JhH1X6Jie42pZB+mex/zC34EwJuwnAJwiaAtfC3qiRcEU8jzyrvMPoLN U0xRA/H6IZwoNaniBJvjVDRjYPtnav7yEG1lWmiF8nfHDAfW7F+xdnAvpEh8M/U7ZmRR Z6JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vXpmgs9t; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si7413711eju.619.2020.11.23.17.55.41; Mon, 23 Nov 2020 17:56:04 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vXpmgs9t; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732122AbgKWMin (ORCPT + 99 others); Mon, 23 Nov 2020 07:38:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:50668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732071AbgKWMiP (ORCPT ); Mon, 23 Nov 2020 07:38:15 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45A9620888; Mon, 23 Nov 2020 12:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135094; bh=WEx00jfl0w7WAFmhjq18LKjOtYIfeZ6kyBaWuxStlBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vXpmgs9tRP3Kk4kooICBcehhKbjmnHGBJs9tNmmDEnBfnw7f1C/+/welf03TNOFyc WB+FCLO3f9dnBfNI0k+xNs74vomsu/JpXi4b8I+KcQnD4nff6bAmZRIiTvim2AvHMQ uDiwBtpLkXuBkG7s01RGfO2RUW4/9e4+n6LBrfIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yu Kuai , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 5.4 103/158] xfs: return corresponding errcode if xfs_initialize_perag() fail Date: Mon, 23 Nov 2020 13:22:11 +0100 Message-Id: <20201123121824.904549934@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu Kuai [ Upstream commit 595189c25c28a55523354336bf24453242c81c15 ] In xfs_initialize_perag(), if kmem_zalloc(), xfs_buf_hash_init(), or radix_tree_preload() failed, the returned value 'error' is not set accordingly. Reported-as-fixing: 8b26c5825e02 ("xfs: handle ENOMEM correctly during initialisation of perag structures") Fixes: 9b2471797942 ("xfs: cache unlinked pointers in an rhashtable") Reported-by: Hulk Robot Signed-off-by: Yu Kuai Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- 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 ba5b6f3b2b88a..5a0ce0c2c4bbd 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -195,21 +195,26 @@ 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); mutex_init(&pag->pag_ici_reclaim_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.27.0