Received: by 10.223.185.116 with SMTP id b49csp8510403wrg; Fri, 2 Mar 2018 03:09:29 -0800 (PST) X-Google-Smtp-Source: AG47ELu3t+S/6v+fwrZ6IrTQpbg04Mv2Ww4hhSKDfL0I7GJRPAAc/nKxKnphKSQ+AwUQmRtxk67b X-Received: by 10.101.74.135 with SMTP id b7mr4283177pgu.260.1519988969079; Fri, 02 Mar 2018 03:09:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519988969; cv=none; d=google.com; s=arc-20160816; b=K6VGm2PipxbJ7UmZSiEOWBAFQ0mKDKvC5I6MQShy3rskkdmRy/ub89Z1YtuJiNLAQl uyZMisr/Tf+UC5ohJsfDaZWMel/mEA+nQgb0Mip5eyoWRja7QKDoIJ4Kr5LnJ3eY/gIX yVDh0k6eghEnOsq+oIKk2Hv/S8J3OjLcGzlqAZ9g1iA4grr5HCYMVVZoY/yCtPcaZTVE k+jEb8C5E4AmGIC7FBwBsZG2ccAOiZyqqZ1Ae3i0fwtGNVFTrIxYbQY1Zuk5OR0GTfYY 6KldkWp1rZ/DdaceO055d7rxOJZvesHBNDSEAWwk7OSJq6pgDBsRX69XTv1M7DeU6oda yiaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=tV6/PTU/vE2QJXbWDTuBDhTgGIUOb4l4ZgVHNNgAWlA=; b=0AljxWP6F9IdTDml0jKZM9SlORhyPYiIyje79shx8IbxPcrebLO373gccCFOYUyQPL ikwhFp7pGseqM3u5GqwxWwvemo0otubxYnveoev8o2EjHNyqhSZQ1QrUUEG2MoEgY5Pl gk3pqnMr2UJBL+1JEjPA1rVXg7tOvmffZ6ptrk+88T7hZXQiu1ljgMYwZPxHJQK/wDMX GMWdB4+T4z7GKY705NFLGs5IHwt4/8a/d5MprtxqnzkC4IlJXma3RxLEKbJxSbUEB8NX JmU1be/hL+LHJQmKyINqNxUAancbP6tkLzUGRkVrZtns9OTtgfJzxpBIoOTehncFjtYk cutA== ARC-Authentication-Results: i=1; mx.google.com; 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 c10si3856110pgf.582.2018.03.02.03.09.14; Fri, 02 Mar 2018 03:09:29 -0800 (PST) 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; 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 S1426886AbeCBLHo (ORCPT + 99 others); Fri, 2 Mar 2018 06:07:44 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50538 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423556AbeCBIyp (ORCPT ); Fri, 2 Mar 2018 03:54:45 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EF933110C; Fri, 2 Mar 2018 08:54:44 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aliaksei Karaliou , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 4.4 21/34] xfs: quota: check result of register_shrinker() Date: Fri, 2 Mar 2018 09:51:17 +0100 Message-Id: <20180302084437.376910757@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302084435.842679610@linuxfoundation.org> References: <20180302084435.842679610@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aliaksei Karaliou [ Upstream commit 3a3882ff26fbdbaf5f7e13f6a0bccfbf7121041d ] xfs_qm_init_quotainfo() does not check result of register_shrinker() which was tagged as __must_check recently, reported by sparse. Signed-off-by: Aliaksei Karaliou [darrick: move xfs_qm_destroy_quotainos nearer xfs_qm_init_quotainos] Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/xfs/xfs_qm.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -47,7 +47,7 @@ STATIC int xfs_qm_init_quotainos(xfs_mount_t *); STATIC int xfs_qm_init_quotainfo(xfs_mount_t *); - +STATIC void xfs_qm_destroy_quotainos(xfs_quotainfo_t *qi); STATIC void xfs_qm_dqfree_one(struct xfs_dquot *dqp); /* * We use the batch lookup interface to iterate over the dquots as it @@ -660,9 +660,17 @@ xfs_qm_init_quotainfo( qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan; qinf->qi_shrinker.seeks = DEFAULT_SEEKS; qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE; - register_shrinker(&qinf->qi_shrinker); + + error = register_shrinker(&qinf->qi_shrinker); + if (error) + goto out_free_inos; + return 0; +out_free_inos: + mutex_destroy(&qinf->qi_quotaofflock); + mutex_destroy(&qinf->qi_tree_lock); + xfs_qm_destroy_quotainos(qinf); out_free_lru: list_lru_destroy(&qinf->qi_lru); out_free_qinf: @@ -671,7 +679,6 @@ out_free_qinf: return error; } - /* * Gets called when unmounting a filesystem or when all quotas get * turned off. @@ -688,19 +695,7 @@ xfs_qm_destroy_quotainfo( unregister_shrinker(&qi->qi_shrinker); list_lru_destroy(&qi->qi_lru); - - if (qi->qi_uquotaip) { - IRELE(qi->qi_uquotaip); - qi->qi_uquotaip = NULL; /* paranoia */ - } - if (qi->qi_gquotaip) { - IRELE(qi->qi_gquotaip); - qi->qi_gquotaip = NULL; - } - if (qi->qi_pquotaip) { - IRELE(qi->qi_pquotaip); - qi->qi_pquotaip = NULL; - } + xfs_qm_destroy_quotainos(qi); mutex_destroy(&qi->qi_tree_lock); mutex_destroy(&qi->qi_quotaofflock); kmem_free(qi); @@ -1563,6 +1558,24 @@ error_rele: } STATIC void +xfs_qm_destroy_quotainos( + xfs_quotainfo_t *qi) +{ + if (qi->qi_uquotaip) { + IRELE(qi->qi_uquotaip); + qi->qi_uquotaip = NULL; /* paranoia */ + } + if (qi->qi_gquotaip) { + IRELE(qi->qi_gquotaip); + qi->qi_gquotaip = NULL; + } + if (qi->qi_pquotaip) { + IRELE(qi->qi_pquotaip); + qi->qi_pquotaip = NULL; + } +} + +STATIC void xfs_qm_dqfree_one( struct xfs_dquot *dqp) {