Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884848yba; Thu, 18 Apr 2019 11:11:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1VJj18G2ainSEcIPscnhHUAsimZ87vbF6ziNabhCtIw6jo6p92Uz8uLm04S90eIsi4bas X-Received: by 2002:a17:902:e4:: with SMTP id a91mr78474807pla.2.1555611061992; Thu, 18 Apr 2019 11:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611061; cv=none; d=google.com; s=arc-20160816; b=PLp2W24SgA2WHulU1SZA2rDB3za0/e9utAVHtItPgI40IRB7z1VD7AdGssU109hzFF HrizRMf4F/4grT6TRL+/NZI4yqmYl4VinnGzpprPzo+Y7ikuLVoJHq+KJZF9cxUUvJBv ErpcJqOuB3IkoxbBSPJJfIJfIkeR/tvW0qEXU1laWV/J39c71rYSS1fJ+52SoIEy1j3n p0JfwJp98J0895JDnggezmlOTJl1nhBDKF+AMGkWqxPszevW04qJGCpIIPrkhQ/ZCIBS p/StkzXbDufUnC0Dk5lykiShdh0ZC4ubi1Bv1fShrOB/iF8112bkJ2CAmYh0Stwxe6lP kpig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C2oe7hK7ehfWROz4CemHAZdJuA66gZd0qgaVvYdAXvY=; b=DRc3JMjynb+xHpaDGfddeUCCUag1v6F42H1P+KRFO/UoFE9GvzBHPMlBNPt32AKphh K0w3PSyL++1XYAXZX+3o3iYaqR1oT4219x8fEqPDHidQYtXrsC/yWXMTWubfTCHRtoT3 fE0qXzfq5SM8w4vzhohIFSWaj0VTscnMaXcYvfBnq6wzO9448xG3445fW2GoQHcm+EvL NgrO1JSI9sqJeurHFiFYzLWNTbIYKC5yII30jw6xXs823iDlbg1RscjCmHzZq/beoGBa 6xWXehV5fDZIF6yVQONXfzZRfN2Yphl4Ik5dkrhPu09BIlx83IMjWoHrrIkhJeWYSj// KJdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U881gsNO; 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 89si2849299pfs.243.2019.04.18.11.10.46; Thu, 18 Apr 2019 11:11:01 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=U881gsNO; 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 S2391688AbfDRSHy (ORCPT + 99 others); Thu, 18 Apr 2019 14:07:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:38818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391674AbfDRSHv (ORCPT ); Thu, 18 Apr 2019 14:07:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 7A765218CD; Thu, 18 Apr 2019 18:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610871; bh=SubnmXVTigIc6qg8VmGuLz4RGuw8kx6X90Rjes1mBVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U881gsNOKg1DpqvZkEtQKsPfO0NQ4RoHr214TXRCSQsgM6ms4fr42AafvpY9fYT8V O7Cogl5TimNeYcO3kwQwGrJkJewdoTc3qBWp1h4qst+0sLc4EJi2thmKbWmgpaP/JB 6Vj83JGBZDK6dHElZ3NiYIrfh1vy47JA/tk+LzLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Czerner , Theodore Tso , Sasha Levin Subject: [PATCH 4.9 03/50] ext4: add missing brelse() in add_new_gdb_meta_bg() Date: Thu, 18 Apr 2019 19:57:14 +0200 Message-Id: <20190418160423.140134259@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d64264d6218e6892edd832dc3a5a5857c2856c53 ] Currently in add_new_gdb_meta_bg() there is a missing brelse of gdb_bh in case ext4_journal_get_write_access() fails. Additionally kvfree() is missing in the same error path. Fix it by moving the ext4_journal_get_write_access() before the ext4 sb update as Ted suggested and release n_group_desc and gdb_bh in case it fails. Fixes: 61a9c11e5e7a ("ext4: add missing brelse() add_new_gdb_meta_bg()'s error path") Signed-off-by: Lukas Czerner Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/resize.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 67b359629a66..e16fb545d441 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -907,11 +907,18 @@ static int add_new_gdb_meta_bg(struct super_block *sb, memcpy(n_group_desc, o_group_desc, EXT4_SB(sb)->s_gdb_count * sizeof(struct buffer_head *)); n_group_desc[gdb_num] = gdb_bh; + + BUFFER_TRACE(gdb_bh, "get_write_access"); + err = ext4_journal_get_write_access(handle, gdb_bh); + if (err) { + kvfree(n_group_desc); + brelse(gdb_bh); + return err; + } + EXT4_SB(sb)->s_group_desc = n_group_desc; EXT4_SB(sb)->s_gdb_count++; kvfree(o_group_desc); - BUFFER_TRACE(gdb_bh, "get_write_access"); - err = ext4_journal_get_write_access(handle, gdb_bh); return err; } -- 2.19.1