Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3065958pxb; Fri, 5 Nov 2021 09:12:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0SP2B6EWIZ4Sd/ONLCFMkEcTRUHcOnAroVqMYVf+rGn5hAePjl+CuIfgaiqzj2Ek2A9Nw X-Received: by 2002:a5d:804a:: with SMTP id b10mr35423ior.197.1636128746776; Fri, 05 Nov 2021 09:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636128746; cv=none; d=google.com; s=arc-20160816; b=gxMjZ5RMi00L0b8Mbqzk5nRFFCu8seL7SbBz70A7wCTt8iS1Zjkojlparv5ee4/7jp 0LHulClrXsZBHMC8vySF3szpsW2E8zmHDWDXTv/Sn3/hLwnmBv+/YurmnuFPo7U3onaL ngEQeamTZdyHcng3xl6YqDV8ouuhutsY1XsOYfsBZk8RdNcsYdoYcUOA+20dtQSNrRJb mVcvRG60IVsp7sELO6dk4fBuKphOv3N8MGNgVEPiv6C5r4SA6asRXhfIt/hmOmwnZr+B LMjTGOx+kbP1puF8B17/umYalOeqUrHgP1WmITCwaB1JX+6VI+l4n4QaUzvFET25rrdj lyyw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=nKIjEb5Yv8HBHDFmUvzd+2fqO8xFjNm/WY/dtDGO8lw=; b=ZR1sI8yWXR2O6OI1Dcw43bE/1cy8XwcQ2NsM1yZYh00lETEiahls6iES9ClxaS2hgY X14Jv16PVv9wCQ7mT4tP/X0cuEarY3FDYxNP1MGUDWig9hTbSxgKwI6dtMBj4ei/ntbh X1rtNNnvUMwmLvE/6QJfYKsOwjlX1XqqvgCI081kuQx9X6zHn+1CS/hFIWmwvGFXJCw2 /ahKnkEBGdKsYAw2LRrA0Jw91zsWn4lagmnUipLcuwMI15UbXR0S9LeUyort9DyCltsC KQ5nUas8ZUcePi4MOoS2HQn+oxxolIMK5FRWkqO1ThdG3bkNz+AllvspZDndlcgxLOMM Tk8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nNeZINJW; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si10891764iot.96.2021.11.05.09.11.50; Fri, 05 Nov 2021 09:12:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=nNeZINJW; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232758AbhKEP7z (ORCPT + 99 others); Fri, 5 Nov 2021 11:59:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:46002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbhKEP7y (ORCPT ); Fri, 5 Nov 2021 11:59:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B82E60230; Fri, 5 Nov 2021 15:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636127834; bh=kWFhx70/FEe4Ay6ZeSIn3AZkUcCPD27adLUs5+hkz1E=; h=From:To:Cc:Subject:Date:From; b=nNeZINJWupDgDvSJvzsreSJXv4KlFuqj6JfQxD98b5jFQZ3WUDpBqYWIiDv/VVmYU OdW/GBhgvg89JDoNiTzmA+s1MpbGqJEWSLQAd31R7BXExp7TZZr6gDbRUx1YVybk/A g3RnphxF8zWNexZKDZeQDflJWFdhCWk+mPShBa7HJCOmxtklpI4P5Q8yqUkr5fJSWA 5sSZFT39D3YJD1tetpV5q/AWsPCzckMUx5nXGCcXFQ0yiaHyq/rGXaJ6Gw0R78VTnX 7Js2ACYIamH7qQkspZGu1W+ZAPX7divU+Ph7YC8Lg3lioCP2AHIv2IiwvINYrioPCW WASlBTkSk6lTQ== From: Nathan Chancellor To: Trond Myklebust , Anna Schumaker Cc: Nick Desaulniers , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nathan Chancellor Subject: [PATCH] NFS: Avoid using error uninitialized in nfs_lookup() Date: Fri, 5 Nov 2021 08:57:04 -0700 Message-Id: <20211105155704.3293957-1-nathan@kernel.org> X-Mailer: git-send-email 2.34.0.rc0 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Clang warns: fs/nfs/dir.c:1772:6: error: variable 'error' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] if (fhandle == NULL || fattr == NULL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/nfs/dir.c:1801:44: note: uninitialized use occurs here trace_nfs_lookup_exit(dir, dentry, flags, error); ^~~~~ fs/nfs/dir.c:1772:2: note: remove the 'if' if its condition is always false if (fhandle == NULL || fattr == NULL) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fs/nfs/dir.c:1772:6: error: variable 'error' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized] if (fhandle == NULL || fattr == NULL) ^~~~~~~~~~~~~~~ fs/nfs/dir.c:1801:44: note: uninitialized use occurs here trace_nfs_lookup_exit(dir, dentry, flags, error); ^~~~~ fs/nfs/dir.c:1772:6: note: remove the '||' if its condition is always false if (fhandle == NULL || fattr == NULL) ^~~~~~~~~~~~~~~~~~ fs/nfs/dir.c:1754:11: note: initialize the variable 'error' to silence this warning int error; ^ = 0 2 errors generated. Add a label to skip the call to trace_nfs_lookup_exit() when the call to nfs_alloc_fhandle() or nfs_alloc_fattr_with_label() fails because trace_nfs_lookup_enter() has not been called at that point so tracing the exit does not make sense. Fixes: 8d3df1d0387e ("NFS: Remove the label from the nfs4_lookup_res struct") Link: https://github.com/ClangBuiltLinux/linux/issues/1498 Signed-off-by: Nathan Chancellor --- fs/nfs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 8de99f426183..1c978a7cf730 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1770,7 +1770,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in fhandle = nfs_alloc_fhandle(); fattr = nfs_alloc_fattr_with_label(NFS_SERVER(dir)); if (fhandle == NULL || fattr == NULL) - goto out; + goto out_no_trace; dir_verifier = nfs_save_change_attribute(dir); trace_nfs_lookup_enter(dir, dentry, flags); @@ -1799,6 +1799,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in nfs_set_verifier(dentry, dir_verifier); out: trace_nfs_lookup_exit(dir, dentry, flags, error); +out_no_trace: nfs_free_fattr(fattr); nfs_free_fhandle(fhandle); return res; base-commit: cb66e0e973daa668dadd43441f877377a1b7b1ff -- 2.34.0.rc0