Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp895001yba; Thu, 18 Apr 2019 11:21:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyx9qQLIhOLny8kbfBMdbOSc1I16pBsZXG6bp5qwQZgpuMpsizvGMYGmMzq2FtbyW0M/GSn X-Received: by 2002:a17:902:2a6a:: with SMTP id i97mr42085293plb.273.1555611704935; Thu, 18 Apr 2019 11:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611704; cv=none; d=google.com; s=arc-20160816; b=bKgLo3nzwKoGrd1PpGrss9jOSDEyvidqgAzFdt8r+RYL4Gg6ZEsatZwTAj840HWr5I qng7f9AlIX0eh8f1Jsx4UFrmXvu7IWZy04OqdR+ecl8RBHwvW83UFrefm4IRFytjU+Q5 UvREQizxN1HHrm8v/sj5WZc00aHd5fkvAVDrfhk5Lf5SGZ6IH1afsl7+v1tKzLYkFKFZ gTE2EVDLMps8snDxKI/MM1v7FH4g1RN1qCu/Vlyyqa7DXnqJYOlIwyaVhhi4vBfR2QEN 7uam0meOB+2TDatVsZSnOTPWouYnSwzaV9eai9D1egW7LSeLmm1Oh8pffPLn6sgWrQ+t A9LQ== 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=SIk0jQ9SXxz8HNSoVdLyyhmvLvEmB0AsEBTaumrILEo=; b=XFMP4ANzw67eG3+peM5/XH8N970iFMkR27iETQGzr+LWGJ4BbkDUXynJJtpzRuB4/x 00jZhGGPsGTuMjmpgXe0p78l9nO36Bd9Eck7T4/+JV1iXsrFAAduOTs7kemaMQNiGbaT CYFISz1w/uWyKOgVBAxf8eZiqivUPVM9d62B6TCxrKeoWBF0omUINAOgyt4ozIpEcsqD QWx/CBxfMV6o0TJeI/EW47vrJBBYo3pazv4Bn+CPrxcV1FdXODQlKJgPxFG84NMQUlWX f6PpbzMEHlXHKhc0uHtUgR1cywqt8QTus441DDyA8Z7S7LR/+KclGOf5IYHGM1L3U6Ld u57Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="c/LRbaOJ"; 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.21.29; Thu, 18 Apr 2019 11:21:44 -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="c/LRbaOJ"; 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 S2391672AbfDRSKb (ORCPT + 99 others); Thu, 18 Apr 2019 14:10:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:42242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391539AbfDRSK3 (ORCPT ); Thu, 18 Apr 2019 14:10:29 -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 5A1D1206B6; Thu, 18 Apr 2019 18:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611028; bh=/7PvaA4MTYVn1/1EBnANmgriFF4k5g7ONuPAPVG8p68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c/LRbaOJ0oOutF39sECBnjWLGR175LOr7Tz2ShCWZGQJzcQBG4iZeGsGTHiJEbPzg gcN9iflVbyxurb/Jt8buqbaJcv0wBodYoSc8xG3c2rK0x6in0U3tLlDClVS6/0kN+U PsoXK4ssECWV9zb1UjJZrVwKtQorq2Xb655L+bns= 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 5.0 08/93] ext4: add missing brelse() in add_new_gdb_meta_bg() Date: Thu, 18 Apr 2019 19:56:46 +0200 Message-Id: <20190418160437.845355313@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@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 3d9b18505c0c..90061c3d048b 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -932,11 +932,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