Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5187699rwb; Wed, 21 Sep 2022 04:34:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Ako2vyeKsXVIAk9I84C+tHyhdCIZ2m04NfvUg+Ukpksuttafuq0HAwR+vUlvNGe3JNC8+ X-Received: by 2002:a17:90a:e60d:b0:201:6b28:5406 with SMTP id j13-20020a17090ae60d00b002016b285406mr8873423pjy.228.1663760057196; Wed, 21 Sep 2022 04:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663760057; cv=none; d=google.com; s=arc-20160816; b=F77aWF3WxgNnTONc/d/IwtWdFFxboxaWTKrzuyFUZNulu6NeyDxNmxdk6uoeOC8cAA AioC2lfsJIcLz4QUgqFQRefdNBDJbeAAXA8NxEfDpG66n+DBjhzG5a5ssY5tyLOcwvSN B0SxgSe6Q9PNEABFwtWELP/VpFYdDYpgvTWH6kqxV2lFdS1WwSu718QGvU6MjpOp9vYI z2+l1S2Avfc1bKAnQKl45Dxoov9FlCjuh8c3J4rsXGsGK/Ncf/QxE4rHnneSMFS4HN0p +j5y7xPp89T7rOovxUa3eFdYNsoQ6BOk2OWDcFEidIRkOfpLwNhimZVNZagf3hehWCoU 4v+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=dKyBnaUQKclgSFDRAU7XBhYoWw2RHfeoGLz/adPg6nA=; b=vpIyjxYiTEaUgsI5US2CuVBL5vIMzGt+j+DWXKzZdcPPwUptVUVbJ+AsaqMlLdp9FP v3ocaoO9OudKAR7oRiYk7Eq9UaV+6tiTECszo+BUIfznAH71lhnvVJIiMnCwQIlY5drU wxLEwvxMPp7kkNmeVnKV0VgPjBCLunwKRZO54ohl9nLuIrctRJACTJoihhjO5RMSx4/f 0xJazQg/KUcomFc7/ctX8c/6/oVlj+q7oTpmVZAmewFx76kMjXcNVJLKUwwKXbMUz9th v7h/exkI/5WODgwgSqpYk60RfjIDMCif+XUD5/kAoXFoVrysaOjf0/GW20Zai0rKhktc hMmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Qk90BVk3; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a17090a2d8400b00200b2891af7si2382401pjd.66.2022.09.21.04.34.03; Wed, 21 Sep 2022 04:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@suse.cz header.s=susede2_rsa header.b=Qk90BVk3; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229498AbiIULbK (ORCPT + 99 others); Wed, 21 Sep 2022 07:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229723AbiIULbJ (ORCPT ); Wed, 21 Sep 2022 07:31:09 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73EDA86882; Wed, 21 Sep 2022 04:31:08 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 142DE21B2C; Wed, 21 Sep 2022 11:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1663759867; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dKyBnaUQKclgSFDRAU7XBhYoWw2RHfeoGLz/adPg6nA=; b=Qk90BVk3NGPouon8Zpda33keSHA/rl821O8OsRuhRJxh1FXxQdHGr1HO5r7i4l7QuAWnc2 7ELmtGtgG8vL+99X/MzETA0yVli9jan6dUOPsZnzjbYyrMfutuoIroItjH4z+0jETsvu1H zqfQUBw8e56raucj1CWZfozJJqZw9mc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1663759867; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dKyBnaUQKclgSFDRAU7XBhYoWw2RHfeoGLz/adPg6nA=; b=92cKdXVluB3+zHVHzGXROLCPu+qdi8E1xHsQEmVcQrUZ9Z/TOeAasJgs9QkovYdbY5qvMD WcJnEcDbEVtiqZAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 04EB213A00; Wed, 21 Sep 2022 11:31:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9/QsAfv1KmMjBAAAMHmgww (envelope-from ); Wed, 21 Sep 2022 11:31:07 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 44028A0684; Wed, 21 Sep 2022 13:31:06 +0200 (CEST) Date: Wed, 21 Sep 2022 13:31:06 +0200 From: Jan Kara To: Ye Bin Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, jack@suse.cz Subject: Re: [PATCH -next v2 1/3] ext4: fix potential memory leak in ext4_fc_record_modified_inode() Message-ID: <20220921113106.mk4h4rjdfpwdkzs6@quack3> References: <20220921064040.3693255-1-yebin10@huawei.com> <20220921064040.3693255-2-yebin10@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220921064040.3693255-2-yebin10@huawei.com> X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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-ext4@vger.kernel.org On Wed 21-09-22 14:40:38, Ye Bin wrote: > As krealloc may return NULL, in this case 'state->fc_modified_inodes' > may not be freed by krealloc, but 'state->fc_modified_inodes' already > set NULL. Then will lead to 'state->fc_modified_inodes' memory leak. > > Signed-off-by: Ye Bin Still looks good to me. I think this didn't change since last time, did it? Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/fast_commit.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c > index 88575f3d0dc5..29a22ee0adb8 100644 > --- a/fs/ext4/fast_commit.c > +++ b/fs/ext4/fast_commit.c > @@ -1486,13 +1486,15 @@ static int ext4_fc_record_modified_inode(struct super_block *sb, int ino) > if (state->fc_modified_inodes[i] == ino) > return 0; > if (state->fc_modified_inodes_used == state->fc_modified_inodes_size) { > - state->fc_modified_inodes = krealloc( > - state->fc_modified_inodes, > + int *fc_modified_inodes; > + > + fc_modified_inodes = krealloc(state->fc_modified_inodes, > sizeof(int) * (state->fc_modified_inodes_size + > EXT4_FC_REPLAY_REALLOC_INCREMENT), > GFP_KERNEL); > - if (!state->fc_modified_inodes) > + if (!fc_modified_inodes) > return -ENOMEM; > + state->fc_modified_inodes = fc_modified_inodes; > state->fc_modified_inodes_size += > EXT4_FC_REPLAY_REALLOC_INCREMENT; > } > -- > 2.31.1 > -- Jan Kara SUSE Labs, CR