From patchwork Mon Oct 24 11:27:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp550606wru; Mon, 24 Oct 2022 09:46:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6M+9AlikOVqz1x9QnEiPrn+0eRPZAukvnbU17ZCEp2D6g5uQ3hT6J2a2naL+FNxh5QuOvm X-Received: by 2002:a17:902:bc46:b0:186:a8a8:e9d9 with SMTP id t6-20020a170902bc4600b00186a8a8e9d9mr6096877plz.13.1666629983687; Mon, 24 Oct 2022 09:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666629983; cv=none; d=google.com; s=arc-20160816; b=Wa0YM0CJ0yaN8oU/RjGPqRRQtfbVG9U6Qg1pmveXa0C5syzkT2YYTfvEzTpXM6BUJI Bdp7TrYhkfyvtLy0H4zQ8E++WYHhY8sItSEk3h1VzgUlZJ5byTQ0LhY/KMJ+vabWvA8w +1oow9Lym1CexN0QBhPE3AkL413eOB2R/rVYWR8nVARHo2h2bkY+qLRjoQkrsLPmczVl RVFjW8AGMSfejHRseV7kBu1rO2327XY/sIN6nzhXVyrrHvXInJHcs7hcnJSLK7hCpwPq 1+Jy0xZ78KIKCXVUfTQh7UAoPHPC/YGuRZcOC2iWhcx/lLNCKWfI7uzFyQecuBI76mMe fNXw== 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=P1eKZv4sHdtr5+5hY/4c5gczX9CQX+0LwlOVfj4E+ho=; b=we0pryHfgPr/Wo0tH4kYArhnsvOKeEXUjZHEq6Sb2flXmA0OJxwk7r1zxc6IYviaE3 RUReSCw04mnTHYxTUsCSgBMY/3uyd4mS70imnI6o6qiTdLZ+8BfXnKyoX9IgJ8LLgm8O twHtF0tbBbLzb+cK/PLvWl1K4+lLpqT1n10iNyZVRzD8Kxsznp0auCd4AAvvDLVtM8yE 631Dp73E3QCnwkSuz98elFtECd1DV641l75r7LafF/+welGH0ZWqz2RcZoEOM7QqDcPp Z5mm71y/dZVTbVPu7DveMbRuEahHcFCrTgCZcOH1N2yblwvg9RgubwtSyHSSUhPhK2js 9g/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=amJ4E1mX; 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 14-20020a62170e000000b005623e8c0abcsi147364pfx.151.2022.10.24.09.46.09; Mon, 24 Oct 2022 09:46:23 -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=amJ4E1mX; 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 S234950AbiJXQps (ORCPT + 99 others); Mon, 24 Oct 2022 12:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234400AbiJXQoY (ORCPT ); Mon, 24 Oct 2022 12:44:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16CB5CD5E6; Mon, 24 Oct 2022 08:30:41 -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 ABBF8B818E4; Mon, 24 Oct 2022 12:38:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1956DC433D6; Mon, 24 Oct 2022 12:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615130; bh=Zrt1TG9R7B7K0iehR7+m/EKVHsRtYzX75DOp8vvGmX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=amJ4E1mXNh9/i9MiTtuWmaglBsBK/wXbNem/iZLgOOX/3FzoLeZ0SiwCo/4ioWKNc kPjHZHQr2nynTVYRLa4lGoIs3HGk9kWRwXdGwK8/D8UPdBQTbmJM1hS+3gUTDdhLv+ 9h6hHS3XoijSvQZxE5ZW7k8nak/TfLF7xYxTiEto= 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.15 103/530] ext4: update state->fc_regions_size after successful memory allocation Date: Mon, 24 Oct 2022 13:27:27 +0200 Message-Id: <20221024113049.681180790@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747588201521798327?= X-GMAIL-MSGID: =?utf-8?q?1747588201521798327?= 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 @@ -1609,14 +1609,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++];