Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3314988pxb; Fri, 5 Nov 2021 13:29:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcYM4Dx6ft9FwH5T+3bmu9NYVJrKyTd8ogpky8ztgpFNQGKkTbRbXctJ8lUgfqoX1BVDHK X-Received: by 2002:a05:6e02:b22:: with SMTP id e2mr19802882ilu.73.1636144199409; Fri, 05 Nov 2021 13:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636144199; cv=none; d=google.com; s=arc-20160816; b=jyoJTrGHv4a+F8Zj3XvNNrEUPjqhndK5Atq5iAmA8oFywMrKukPolrzxFZ0wmfjAZj Ln6Rn0wwEsPuzpP+MVB/OAEcf0j6OjdPdDwnA4PYEg6Var4i6QTsm5uAG3kGWrWf/7iI CQpC5uPbv1lbkqgMRPb8TEvntb4YJRKSUBg6aN6Z59m0Qi5OQEJi9IjXs37Z9DhulQ/9 8/qCMIz7/ttcwOzLJRnymX4ZQibolKOvlmX5uh9KWIw88+f7HgCSOtqNS6+GKa65P7UD Kq5lulpIPRNtoFEQM2SSm+TqFp/tUFbd5+Uc91s+YFfrDYpSYcYFvndpA+E6sXgsMV9j 1s5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xwqxqNONZ3nCcXRzI2pRNIMYNqvPW1JqDX8ccOMQAOo=; b=JM58Go/E+XgqtP7Ulq2mBlyvhOtsxrTAegFxW86NAcvhouqa3knRbXjBjVprxgH2AI rT7A1A218b1hPPV6f+melJZj2yLSGojVOh70TSOktv+15Cz3SpX+jnh+j+O5o8gxjkPc QiuKVjFbkngXHQWhTVZAEAJrG+1W4AF5wcL15ZIN1cp13GVyuxJNP+CR/KQWDNxCpSac wCA2EiKMhOtZULT+TlUs874rTjqvbALVd2bNCHNxgqtNSDESz653UtCExLxcSQXNO4wN FqZhKNF91e0jDICP2Wd792DdzNaeisJ8BHxyBd4unEySoqj5TUuYux4PCc4t6kZBH/+M /n7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cNTdYA8k; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si17438358ilu.121.2021.11.05.13.29.34; Fri, 05 Nov 2021 13:29:59 -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=@google.com header.s=20210112 header.b=cNTdYA8k; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232742AbhKEUEV (ORCPT + 99 others); Fri, 5 Nov 2021 16:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbhKEUEV (ORCPT ); Fri, 5 Nov 2021 16:04:21 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35F2EC061714 for ; Fri, 5 Nov 2021 13:01:41 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id d23so16744326ljj.10 for ; Fri, 05 Nov 2021 13:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xwqxqNONZ3nCcXRzI2pRNIMYNqvPW1JqDX8ccOMQAOo=; b=cNTdYA8k53vnPjLAG/Ja74NhguL/6mBPtbcxEWWpKkZOBcFlUWJ0F+o3AqrSfaredo UmHsK6489n7iftCUHjEpEvQ64Is/sdNcBf+nZay45joT1Nb5Zgp0PZfjG/zyf2fNdwie eywGZl6+wInFHO+ISbNXtW1BOJSsUlWjrlvJHsz960+Lm/26ydNIJpE76HWYW8RWYcBe g7yXDPCSx6IdGGlckfRhL6WL4YdEjK73jm4DaxSLsAk+a39i6dESjUG8L8++dl/PzvgF ewKD0EEnk+4+bYlGwNBx2+q1dRQii9yetfdW5MpSmRklqQbvH1VyX4G6VDKrPM4HVkVs AT5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xwqxqNONZ3nCcXRzI2pRNIMYNqvPW1JqDX8ccOMQAOo=; b=7pzY9jDpSqXJ0qfrVTVY2OcTwzAkpug8tE3KwqUuFQru8kI+zlzup3ux0z468g3wAE bvucIQy5LdTYxgKT/YzFY+BPNDC5q6dQCePvOdYZvbD8+x/ooa2lZhPeHX5TKQ3tCoOB TWiQ/+E3o216jZFKhhLHnIDOnn0eovwFFfuL0bwN4L6VKeLzITgH+nw8UNmftG5Xug0F puWX0M2B2Qbu0yzR3Mv6NfJ9Q728GWch0BlW6Vk7PhCZ+yejUFFBU0LSUhBN6iuC8j3T 6W5rtOup2QKTdDLuy5ECKlSaP+qhI2z6kf29KG1BUTUDfB5blW254wcYPl6mGe6tzmR4 1hJA== X-Gm-Message-State: AOAM530dohty4Hb877tKpAkTO1eA8AHGlv6IsFr/4g0OsDJSa9NrHKbr nk0P7o3dqb071HoiAo5EVrjHBmMIWgZPI1tpDkKl7ET790k= X-Received: by 2002:a2e:3102:: with SMTP id x2mr7143024ljx.62.1636142499158; Fri, 05 Nov 2021 13:01:39 -0700 (PDT) MIME-Version: 1.0 References: <20211105155704.3293957-1-nathan@kernel.org> In-Reply-To: <20211105155704.3293957-1-nathan@kernel.org> From: Nick Desaulniers Date: Fri, 5 Nov 2021 13:01:27 -0700 Message-ID: Subject: Re: [PATCH] NFS: Avoid using error uninitialized in nfs_lookup() To: Nathan Chancellor Cc: Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Nov 5, 2021 at 8:57 AM Nathan Chancellor wrote: > > 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 Thanks for the patch! Reviewed-by: Nick Desaulniers > --- > 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 > > -- Thanks, ~Nick Desaulniers