Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1397862pxf; Fri, 9 Apr 2021 07:29:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSXtykG8AIN3I19S6sBzj8hfLwIWN98EFxE9JqPsP3HALYEfmtKheJsw2o0oUQZ3ypq8OB X-Received: by 2002:a05:6402:151a:: with SMTP id f26mr17920448edw.43.1617978595952; Fri, 09 Apr 2021 07:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617978595; cv=none; d=google.com; s=arc-20160816; b=J13UMhj2t1yjVGKuCDCMeHiINEjFwmgnJLrH5YcSXblm2UCOLRoVf/Oakudzi0UccF PRPj047mFy571XmGxFe5yG4qnAANJBY14QxOVetBDWxzy8Kr+ByHVqtRqiBJbk9IXNUi NopW0yvkwSPDMA2SDbLkk5Kt9gEgooeYuo0mD6S5QEowznP0GmOnmCcj0Q85mJqIgH+T reYGfVUt8Dgtjo52QWFDmkZtsa2bYqg+TElkyXa76E9gpSgctaVfuyOB1K5+LF18u+Tn Ty3jYsrKKkzUygZSFk5tloKsfDfw5XFAhY7mcioJPtGDXM2vqwOwJR68AwA6wtl8omkD rZiQ== 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; bh=2WeIsmkBPBWNxXOoVqWwCuAdvoknN3d8B+ES3b+K120=; b=fyp6Yqt1tJs0hcWZVBEEL1qpG4jtTmmHp6DNKU8SyzBZ4fWxdRTVt+A9d2xkHK+YNU Mp7N55i/l8uGRUVd05jBjdKy3CJOa2PG1PuN7FZt6+bWH0LWOMqTdMaG38rqUGDhvPnN GrvbIkjN/IEFbNm4wbcCOILHcp3H7wl7UagJ1xLn1f9S+i78t/39vCkA8ZwfhxgNYo+N iC0o0WPrBlaIepJbxlhuh65neGVlZdT7v1UhBZVDv9yKgEfDydkjHeJO4Uh4SAS7e30w 7zoESG2NFVHMLtZTEEjuBsMkvcrEYsOdGNmpVxKLnoHBwuIBwTT6q8mpUL0V5RCmTT8u SEFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=If3EVw61; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm24si2218330edb.297.2021.04.09.07.29.32; Fri, 09 Apr 2021 07:29:55 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=If3EVw61; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233752AbhDIO2w (ORCPT + 99 others); Fri, 9 Apr 2021 10:28:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39434 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233569AbhDIO2v (ORCPT ); Fri, 9 Apr 2021 10:28:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617978518; h=from:from:reply-to:subject:subject: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=2WeIsmkBPBWNxXOoVqWwCuAdvoknN3d8B+ES3b+K120=; b=If3EVw61V37C+bSdB4gRB5XrYnDvQdeRTzRd/8FzFDqN3bvr24y9cwUp1KItMotJ/oMCMF vz13eM0J9UUwIE+AXnWH2DzCR0r69G4Fza+at2RCtIzZ6IJHolfzf6rQt+V+DBcBI6lhzs 5N+Shf+XCSQJi6Dbj2tA+XsPN+Mnt48= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-266-7qX4dOamNAW1DdDOjY-5tg-1; Fri, 09 Apr 2021 10:28:34 -0400 X-MC-Unique: 7qX4dOamNAW1DdDOjY-5tg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38A1E106BB23; Fri, 9 Apr 2021 14:28:33 +0000 (UTC) Received: from bfoster (ovpn-112-117.rdu2.redhat.com [10.10.112.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 672B46F965; Fri, 9 Apr 2021 14:28:32 +0000 (UTC) Date: Fri, 9 Apr 2021 10:28:30 -0400 From: Brian Foster To: Colin King 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 Subject: Re: [PATCH] xfs: fix return of uninitialized value in variable error Message-ID: References: <20210409141834.667163-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210409141834.667163-1-colin.king@canonical.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Reviewed-by: Brian Foster > -- > 2.30.2 >