From patchwork Sat Oct 22 07:20:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1094783wrr; Sat, 22 Oct 2022 01:00:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ulAbqkI5+Ty0XZ3gx/EDThXcbPkA2zKzBZTHwKsVedLdnKanB47hu5ehekKEGDSpVmzOT X-Received: by 2002:a17:90b:1d8c:b0:20d:3180:3e8a with SMTP id pf12-20020a17090b1d8c00b0020d31803e8amr26681172pjb.68.1666425657665; Sat, 22 Oct 2022 01:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425657; cv=none; d=google.com; s=arc-20160816; b=HoFEv+05osH8MLRqcy2M1PL39I25GA27OQ3+EI208U62UjctvvwipudkQQ1eL1yxwI X2ForP0H/se/vcyuVSRT4WaU+qmc0WBaW9CkDd6esfql0xAaGx5Cg0M3c0faJ/6WA+xW ZuzE45lbC0b8eX/FVMIkkJtv78IpPHbCcw2QInN3Gk5kxDFR4bG9CO5fJOl32SSgTCcl 0x1y+eyooT1BQKyYN9b1DmJ8+7tFIcYIty9LVbgmbfgucTeSJ+uec1gZFFBDTD+qI6JZ C/EPtH4o7lYWJU15WfmXEMvK/4cPAmC6p0DCcY5kAfzxXTVEhmSH5cY/qMHPsotOmdDw 0udA== 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=yPIBXABU/grs4Zgo5r7FhtFCxRNbAPM4d+UFSeEdS0EE0o8p2sYIl/PQPX+om6Togn 2oMg+yR9iuqMhS4vG216IaSmuceSoW9jK0ngxCL8mCOKYqOJQWX4FP793WmyEEwUtJZK PZsSWPvqU8cRSGxrP0Yoir3MZzXUMYucop0ICLVyGlDYlONTO0A8esegTR5lUGLEh9XN Q6UafqB70EZUvgfvADrdQOdgT6lh4MH83j3teAzOUiuwDNOYDZAjHzdQL66kSQdU39ui rtUdz7x3/fTbAE1oMV2nRMRwLXR/91UyDSl16zC/8hIsZTt3hjlpv3D84hW40bM4bfWf M7ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yUndkd4H; 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 f9-20020a056a00228900b00562f2ff1579si28227917pfe.60.2022.10.22.01.00.44; Sat, 22 Oct 2022 01:00:57 -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=yUndkd4H; 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 S232448AbiJVH7A (ORCPT + 99 others); Sat, 22 Oct 2022 03:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232131AbiJVHyH (ORCPT ); Sat, 22 Oct 2022 03:54:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5583566F19; Sat, 22 Oct 2022 00:47:24 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9EBF360B85; Sat, 22 Oct 2022 07:41:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B362CC433D6; Sat, 22 Oct 2022 07:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424493; bh=pEMmLSxLkhJ7Q0G0EGdPJvux2Lqx48XdeRTTspi2RpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yUndkd4HcluQiG4mSMRcso4B3oAWkjuENJN1FUkp6dQH+kD6tRqUCCL/LXXDjyE8Y +cvySZfbHibLNKpZXTqMc97Nz6nTf5YfKUzjwaZIZCqcS0CoMbOODU0mbW5RSvkpYz aLyr9txU8gfXlsaO+baCd9Kz+hgo0sfFsxUZqo3M= 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 5.19 136/717] ext4: update state->fc_regions_size after successful memory allocation Date: Sat, 22 Oct 2022 09:20:15 +0200 Message-Id: <20221022072439.601141995@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373950260234013?= X-GMAIL-MSGID: =?utf-8?q?1747373950260234013?= 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++];