Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1407193pxf; Fri, 9 Apr 2021 07:42:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/+TCamt+6xIFQDthH2zkZG3zcfx9Gq8ztAjmHZKsUX2HETnDOnp/9DCtQVe9aq1u0I3wr X-Received: by 2002:a50:a699:: with SMTP id e25mr17736190edc.276.1617979363103; Fri, 09 Apr 2021 07:42:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617979363; cv=none; d=google.com; s=arc-20160816; b=EPklv7C+PnCZgmO45o3QfRKTBi9gr4/KBl54BT6WWGzhxAXZiRfyglR4c6tRZiPJx5 5iYwsO+yDIkOSD4X80TUDQU8c3SFAl945NgQnuweHLRcX74q5RSWtqIPWT5Te5ru8yDt 21SOpgF0iWlly+wSwptYyUwhwCfw/0rmBfqcQsjJGobeKedJSRr/AWOQ+9HPESy1aEq8 BuTCFvmYs8QjI+SNaRUjcSO6H8zq3cJhIqAfCaINHwzcNaVfNVhUG1Ki5+vD9KkUVliV jXNXPyTTI+d56fJmuIyF4wJgbpc2DjOdm3yFOY3fvU2X7RDAvdsMVlLtb26Kb6jOfvlC /CZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=i7feV15SasnmbQkmh4B6aXY9VTTPuBb36Qp9rIQV1i8=; b=gWAB1H73N0sIgLL4RY4r0XaQXe9RBPI33NUt/ldmX4MCQafiR+gtPHh/JtFJ0TrV+K jhpy/j4gyG4vRW4drYDDhRYnvqateaM0WEbLHG/1t7J/1X4XI/3N4CVVd/CzZ5bpccxf X7KegNeGXvADr6mKLS+MDkUAaLZHtBSUvCqQ4KHh4GtwJnGUCUjXYlHRJ3TIlBZMFhtV 6zhbAvLnkVvL4WY33ysGMuB3a6R1eFQq72/Ggw9UnOVZllcHfZUReaCLGlBXuX3AqZ0o dSmWehi2FlXSf9109IfeIA3rbGCjED+i/AZBb/gvP6HE6NFQK026tUBGqteqR0snsyDh Ltzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si2537483edj.57.2021.04.09.07.42.19; Fri, 09 Apr 2021 07:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234039AbhDIOlU (ORCPT + 99 others); Fri, 9 Apr 2021 10:41:20 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:49110 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232884AbhDIOlQ (ORCPT ); Fri, 9 Apr 2021 10:41:16 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lUsJi-00069A-Fx; Fri, 09 Apr 2021 14:41:02 +0000 Subject: Re: [PATCH] xfs: fix return of uninitialized value in variable error To: Brian Foster Cc: "Darrick J . Wong" , linux-xfs@vger.kernel.org, Dave Chinner , Allison Collins , Chandan Babu R , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210409141834.667163-1-colin.king@canonical.com> From: Colin Ian King Message-ID: <08de5ee4-28ca-cb33-7c6c-72f133d97b36@canonical.com> Date: Fri, 9 Apr 2021 15:41:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/04/2021 15:28, Brian Foster wrote: > On Fri, Apr 09, 2021 at 03:18:34PM +0100, Colin King wrote: >> From: Colin Ian King >> >> A previous commit removed a call to xfs_attr3_leaf_read that >> assigned an error return code to variable error. We now have >> a few early error return paths to label 'out' that return >> error if error is set; however error now is uninitialized >> so potentially garbage is being returned. Fix this by setting >> error to zero to restore the original behaviour where error >> was zero at the label 'restart'. >> >> Addresses-Coverity: ("Uninitialized scalar variable") >> Fixes: 07120f1abdff ("xfs: Add xfs_has_attr and subroutines") >> Signed-off-by: Colin Ian King >> --- >> fs/xfs/libxfs/xfs_attr.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c >> index 472b3039eabb..902e5f7e6642 100644 >> --- a/fs/xfs/libxfs/xfs_attr.c >> +++ b/fs/xfs/libxfs/xfs_attr.c >> @@ -928,6 +928,7 @@ xfs_attr_node_addname( >> * Search to see if name already exists, and get back a pointer >> * to where it should go. >> */ >> + error = 0; >> retval = xfs_attr_node_hasname(args, &state); >> if (retval != -ENOATTR && retval != -EEXIST) >> goto out; > > I think it would be nicer to initialize at the top of the function as > opposed to try and "preserve" historical behavior, but that nit aside: I did think about that, but this fix does ensure it's zero'd for each iteration rather than just the once, so it should catch any code changes later on that may loop back to this point were error is non-zero. > > Reviewed-by: Brian Foster > >> -- >> 2.30.2 >> >