From patchwork Mon Oct 24 11:27:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp441936wru; Mon, 24 Oct 2022 06:06:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GS/sDPeQq/EXQcBGx6tUK+JuD+8DQk6srumK9IXLsbr9v6EDG/ObXDSfGbjKUouozBoup X-Received: by 2002:a17:90b:3ecb:b0:212:ce31:33c3 with SMTP id rm11-20020a17090b3ecb00b00212ce3133c3mr20153644pjb.53.1666616788404; Mon, 24 Oct 2022 06:06:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616788; cv=none; d=google.com; s=arc-20160816; b=ZtduqlQF4/xdCspXF0ieHqkRfYHJ4PQ5TYs490Rm1FNlzt8rF4BOmTTvQP19wMVUok cJOjjqAsADuQeyO6yY923k1ZQiZnbd77frJ3cvWw7vW+132C0m294ZF+LOSNneClbg8Q 0fuotaZ7lGK7ye0dHP0Q5M7qZFOhQAiCj7lKsFKOfZ6wOJbq/4sT7bRU0Alwb46Q+S7I GnzOdLvMWVe/VSeYPHgoPu7oBKTeWSGPkgY/+yNxZ8pvO4NOWs6uzPATu49GV1W4Zo1Y R9P5xfeE5KCYvUx82OnYdBP2XdGI3EvnRYEBE8mM+E0qgcnfAsDdpyvROi3llE0+Yhs/ 5R4A== 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=e9pqHciSb8F0n4dHq+X4swKD+Y984k6tRnAZhXzVDfo=; b=lXpVmWiBxsI633P1ouW2pBOUyQc8t848ZMX3cpi8rQoOkA8mpiBVcQEWhmep4LYypv ltKxqPovnBCN0p5b5ZV3aBlBodAGMYOe2QR8tFQWTg9Sz2fU550jfbdn3zjd/ikTywNN sYsGETJY6MFFdrB/W3HerQlgPLBtdSiG+flAyFhyxbf63TdBzhNJ61+FhmJKfMCEll3m ZYgu/rauW1yYCjR4CnUUJ64mQ2kiwqpR2FA5bvkZU+uGopa92cGAMuF6yfMskM/EgNwC dLeiRi9n2aljjJ4s43ykfT6iDqOrlAnMsJdjLnjvZxcvrMzjHcoK6QIm+d4MPHBfijg5 LGbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="E7N/fsxG"; 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 h68-20020a636c47000000b0043961d06e6bsi33238272pgc.787.2022.10.24.06.06.09; Mon, 24 Oct 2022 06:06:28 -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="E7N/fsxG"; 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 S235310AbiJXNF0 (ORCPT + 99 others); Mon, 24 Oct 2022 09:05:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235102AbiJXNC3 (ORCPT ); Mon, 24 Oct 2022 09:02:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB1231094; Mon, 24 Oct 2022 05:19:58 -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 913B4612B3; Mon, 24 Oct 2022 12:18:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A68CBC433C1; Mon, 24 Oct 2022 12:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613937; bh=33E8OtbXA+omniS78pGr4BYD5QNAbqZlBs6p6TcOjE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E7N/fsxG+O9YnNEcxiqNLaIAdWoOoBvrPxH7K5DxXfQ18z2cua4x3xF7yCkU+IqJg nKbpeArs0e9vRVrtpYlR8GQjp99JBM3Ijz8cnUyqidZjgPthawVtX9/fzKQqqzcJCq 2xyBa7zKU1OZtwqEY18hWMjm5YElXIeuA+6Rl05o= 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.10 070/390] ext4: update state->fc_regions_size after successful memory allocation Date: Mon, 24 Oct 2022 13:27:47 +0200 Message-Id: <20221024113025.576979255@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747574365247762560?= X-GMAIL-MSGID: =?utf-8?q?1747574365247762560?= 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 @@ -1586,14 +1586,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++];