Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1839503pxb; Mon, 13 Sep 2021 06:41:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSQNdvjHmYuNZ0wceAwo9ngTG0E2oShF0pXDO5Kcx//bhSrHrRglOaQ7x1ut9UqAgINQrl X-Received: by 2002:a05:6602:1346:: with SMTP id i6mr9043628iov.128.1631540492316; Mon, 13 Sep 2021 06:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631540492; cv=none; d=google.com; s=arc-20160816; b=r7ZFbdE7nTBs1XKwUnhwL//jIIKfrPYZXdQDRp0Spt4johahqleteC9uiZhrRRWTpg 3RKDuYuM8fl3QkJw8s04ToPOVYWBHWsP21axziTx2sV3Wq9CkFS9FrJlrpyqN3eTJ1ui ilej903iCM3hOJvCmf6X2TzcSLULKNcMllXIUzJNeeG4BSGORG7SXha0sQ5IaVt2VaEQ yGhpKxtsa2k1co+kbedKmFBObk0bnuvXAmvW8Itul8BhXrOrYinVBdtw+VA/Imrtac7v hhrc5OYsxMdAAIpGuJrYSYOsfQf7Fsf+EipcG4/hzX8q+w3MCGeLFMoq3uumhiMvNF1l y/oA== 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=vJJyEj+x6o+RDCpDi7bA0J9kEbaiC6hCeG0oVushM24=; b=hJykmCc5QzB0lPq+jwL/L/eAZnpPDtaQwsbkNJI+CBuZrzp/sTynCiOs+vorrqoCch hfZguxMNK1woe5Eq8SVAleFHdLm7pht8pFHRTuhB61oOpYNFx7Ss77BZDHMgYS5u99kx gfMyYbnQZTGn7cDKPZpwLE+sLuIH/Og4depsRbWXUi3oGD/bhET/ui9TKe6kMZ+Jl8Ml Pj+BnuSfwWXtJJnfjLx7LNSvIESeoAAKo92WGygycRmm9PrsZzlrWNQMDteRS1GJEZ39 Q5a3M+3plnwFg928RzHjS7oweE4sYaXwo3toxA8Wv3vvNsEGohUXOhJzfZejqcZmGWwe uRyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QWwfxBjU; 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 2si6067061iob.47.2021.09.13.06.41.20; Mon, 13 Sep 2021 06:41:32 -0700 (PDT) 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=QWwfxBjU; 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 S242602AbhIMNks (ORCPT + 99 others); Mon, 13 Sep 2021 09:40:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:58178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242945AbhIMNeg (ORCPT ); Mon, 13 Sep 2021 09:34:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5A2A66112D; Mon, 13 Sep 2021 13:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539601; bh=U+cfFrIDX5ru3aTbl49bfGwCQQShJg+Kt5wFo39IOzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QWwfxBjUSe7ttD4bsxGoua/VKWO18gX9TUJpzLcw/e9hnC0uZDgMWozFSpPxhsV6z w66+gWeYLGZE7quHOEjasDlhtbB2jXUFt/izaQK975xOUkfWDI4vIcfgq5S+QwOm0r n9fDpQIfp33xYUYUVIZY28+DhC7JBMUzJ/cRzEcs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Andreas Gruenbacher , Sasha Levin Subject: [PATCH 5.10 087/236] gfs2: Fix memory leak of object lsi on error return path Date: Mon, 13 Sep 2021 15:13:12 +0200 Message-Id: <20210913131103.309432571@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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: Colin Ian King [ Upstream commit a6579cbfd7216b071008db13360c322a6b21400b ] In the case where IS_ERR(lsi->si_sc_inode) is true the error exit path to free_local does not kfree the allocated object lsi leading to a memory leak. Fix this by kfree'ing lst before taking the error exit path. Addresses-Coverity: ("Resource leak") Fixes: 97fd734ba17e ("gfs2: lookup local statfs inodes prior to journal recovery") Signed-off-by: Colin Ian King Signed-off-by: Andreas Gruenbacher Signed-off-by: Sasha Levin --- fs/gfs2/ops_fstype.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index ae9c5c1bdc50..52c565ff047c 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -660,6 +660,7 @@ static int init_statfs(struct gfs2_sbd *sdp) error = PTR_ERR(lsi->si_sc_inode); fs_err(sdp, "can't find local \"sc\" file#%u: %d\n", jd->jd_jid, error); + kfree(lsi); goto free_local; } lsi->si_jid = jd->jd_jid; -- 2.30.2