From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBFE3C4167B for ; Tue, 28 Nov 2023 16:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343988AbjK1QTD (ORCPT ); Tue, 28 Nov 2023 11:19:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbjK1QTA (ORCPT ); Tue, 28 Nov 2023 11:19:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2326FD66 for ; Tue, 28 Nov 2023 08:19:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79CD0C433C7; Tue, 28 Nov 2023 16:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701188346; bh=0Ag4qaJaVJYeZsmD/Ziq5NjmMiyUyZLsJEveoMz3LW4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PAYeXIcJISUhsgXkvRPJciIHAtJiy3JURj2WtelWdRE52/+33R7yA289mOzSTFPpQ rwvSp+PNfOUOBQH1Ul7Wq1jJD8+OUCi5IgdB99002hA2VEMI461EJ2V1gIkysFpu7N RN3Cf+ilnB3KDSbC3/FaJDuxPCLYlXHUqx26VNbazKoqVS66CESKEjBCMq9aE6UcyS jnrgswmoFSERvHBfI0edS+Js8eB/OusESfzc2lAjul9+/Vs2DD0TrnfSTAUaVMWRlr mKuXnagpjChGo5xeaRCgDhalBQ+0P1TRId5VxBUD9yZLQTTYvJfZ8lRIYJIrVLVAzO wQFQHbq2qH0ng== Date: Tue, 28 Nov 2023 08:19:05 -0800 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Jiachen Zhang , Chandan Babu R , Dave Chinner , Allison Henderson , Zhang Tianci , Brian Foster , Ben Myers , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top Subject: Re: [PATCH 1/2] xfs: ensure tmp_logflags is initialized in xfs_bmap_del_extent_real Message-ID: <20231128161905.GT2766956@frogsfrogsfrogs> References: <20231128053202.29007-1-zhangjiachen.jaycee@bytedance.com> <20231128053202.29007-2-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 28, 2023 at 12:19:23AM -0800, Christoph Hellwig wrote: > On Tue, Nov 28, 2023 at 01:32:01PM +0800, Jiachen Zhang wrote: > > In the case of returning -ENOSPC, ensure tmp_logflags is initialized by 0. > > Otherwise the caller __xfs_bunmapi will set uninitialized illegal > > tmp_logflags value into xfs log, which might cause unpredictable error > > in the log recovery procedure. > > This looks good: > > Reviewed-by: Christoph Hellwig > > But I wonder if removing the local flags variable and always directly > assigning to *logflagsp might be more robust in the long run. Yes, I think it's better to eliminate opportunities for subtle logic bombs by not open-coding variable aliasing. Perhaps this function should set *logflagsp = 0 at the start of the function so that we don't have to deal with uninitialized outparams, especially since the caller uses it even on an error return. --D