From patchwork Wed Oct 19 08:23:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp300939wrs; Wed, 19 Oct 2022 05:35:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4iLjeU/2ljTNGA9aH9GutOqevPnwa4Xf+1ViqP/GQzREridViKc0Yhs46bhAC8zv2vcUoJ X-Received: by 2002:a17:902:f54f:b0:185:4ff6:fef4 with SMTP id h15-20020a170902f54f00b001854ff6fef4mr8444122plf.116.1666182922467; Wed, 19 Oct 2022 05:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666182922; cv=none; d=google.com; s=arc-20160816; b=s5YuPZCfjjdPrzjcQWfYEpuj18TZb01mIZ5vpnw0ccMBarsZ34Mm3Fkwa5wH6ToJoG F/IoL27G2UzoJVELH21A81R+npLJhdOhiXRpps00u0TkAtgP6Az68S0COO+87usprA7e cZAUe1OtiLtFMrX6w7trNvPkU9akFSdg5Bs1CE/Jl9hqAKir+HaCmPvyc/Cb3zrCssZM tbtbd+3Rfjgx1pOi7ywk9thJd2UsiCTOw0S+9nxc+BZHhkWns4mxUSchEHIYh3ZWVvVJ 8LVc/Hc3B0gPeczbAZl7PgdGRBJTOomhHe0d/2VYtjZu2HDwXo3DKnewdol5TW73/EWh 5mRQ== 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=gE1FL/73tnX4zr3Q83H8ZP7oSujxVaiQXOeqwFyp5OU=; b=gai1HHJXmjdJcci6BN/oFmHBnUjMKtq7i/uRpVTa55kz74KWvfyXYAJvzWRP1RX7db s8KYwAeDTdRFMCevyLFRARPdXO0uFMjlTB0AYgfGzpXsBm/JA0DsBy1GNxxgsDl7eiP+ xgZZvh+q5h5DfIRCFlbn94Kvacw555m/mu71POOgVht/YbQS0JtCJZP863dR0bwHKYX7 BdTUGd3Hx814s0MRFtIvzlGGGKdfslJx1dgTqO3D6TngSid4JtXff4w2cpqw30KOMl3w GwGRWNQMn9V4vnj/9i9qYcvLE+GTJMj55sH3h8IBVRM3qe3GiJUn0CwajqgIg2lOiOki zhoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=awbIWSWQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a170902e88e00b00176e85e5ceasi20918375plg.405.2022.10.19.05.35.07; Wed, 19 Oct 2022 05:35:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=awbIWSWQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232214AbiJSMVd (ORCPT + 99 others); Wed, 19 Oct 2022 08:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232739AbiJSMUw (ORCPT ); Wed, 19 Oct 2022 08:20:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC40110B0C; Wed, 19 Oct 2022 04:55:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EC2A0B822BC; Wed, 19 Oct 2022 08:44:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B00AC43470; Wed, 19 Oct 2022 08:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169072; bh=pEMmLSxLkhJ7Q0G0EGdPJvux2Lqx48XdeRTTspi2RpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=awbIWSWQYJSLNnIQo8teebr7cr4ap+cTbPNuBbzs4OjhGQ0rpbaDGAbY0UwOavgjw H9PS8YoRK0U+KHaDnF5fEMmoajgmv27WZW96yxQVRuHqdkYRJBy40UQleQCDZuliOZ iSh/wnz7vHvJcY70IJyuQsf9ztT5VkJfwW5bqWQ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Ye Bin , Jan Kara , Theodore Tso Subject: [PATCH 6.0 148/862] ext4: update state->fc_regions_size after successful memory allocation Date: Wed, 19 Oct 2022 10:23:55 +0200 Message-Id: <20221019083256.535541872@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747119424231464753?= X-GMAIL-MSGID: =?utf-8?q?1747119424231464753?= From: Ye Bin commit 27cd49780381c6ccbf248798e5e8fd076200ffba upstream. To avoid to 'state->fc_regions_size' mismatch with 'state->fc_regions' when fail to reallocate 'fc_reqions',only update 'state->fc_regions_size' after 'state->fc_regions' is allocated successfully. Cc: stable@kernel.org Signed-off-by: Ye Bin Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20220921064040.3693255-4-yebin10@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/fast_commit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1689,14 +1689,15 @@ int ext4_fc_record_regions(struct super_ if (state->fc_regions_used == state->fc_regions_size) { struct ext4_fc_alloc_region *fc_regions; - state->fc_regions_size += - EXT4_FC_REPLAY_REALLOC_INCREMENT; fc_regions = krealloc(state->fc_regions, - state->fc_regions_size * - sizeof(struct ext4_fc_alloc_region), + sizeof(struct ext4_fc_alloc_region) * + (state->fc_regions_size + + EXT4_FC_REPLAY_REALLOC_INCREMENT), GFP_KERNEL); if (!fc_regions) return -ENOMEM; + state->fc_regions_size += + EXT4_FC_REPLAY_REALLOC_INCREMENT; state->fc_regions = fc_regions; } region = &state->fc_regions[state->fc_regions_used++];