From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 185F61C7D9F; Thu, 6 Jun 2024 14:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683710; cv=none; b=quXtfv4b3LBjshz6iKpFLUWU/0vGdGArHjiXTYs3qtkJte3ape1g+juv8lTz/n0gG5jCidbTyK4itzXcPt3Y5VTHidDa8+jCMWukv/mIfxcfAQS4oX+p2YnuwmzsrnAz/E1q1FdgmWLfHh5wIzqhuIJvRDiDrLgizsd63IFBBgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683710; c=relaxed/simple; bh=9cQyIkVBQYCVrg7jeEBseIgnJrV/OCcCeV5/aabzW6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TjxgFSrw8DZKrryL5kPvn1zOzJ185xs4Gn5CqIwH4GdJwRmgVMAJ7jfWlcDGfnKISYA7aQGXisB+sUIL96EfAujAIIUJGpgSew69NJHZan4iBHhabTrD77hROgter9U3deuJHMACcoW/BjavVnZkcwtUuRvTk60AznDmcsPQGJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M5I/7Gfv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="M5I/7Gfv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE2ECC32782; Thu, 6 Jun 2024 14:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717683710; bh=9cQyIkVBQYCVrg7jeEBseIgnJrV/OCcCeV5/aabzW6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M5I/7Gfv7jMmSXRaSEr//Yzn6FJoXQH37dN2dUcFHta7EDS+LohsxqlOSvc0nOB0M bMjaw92aT7TR+dBsOZ/FE5wJ9yyZE3FO2+qlr2le/BbmzEiSF8a5FodRFbQjDQOUQD twASmoROL5EAx7dAmYKMEfkK6aKyI6dH018C9+9s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Benjamin Coddington , Chuck Lever , Trond Myklebust , Sasha Levin Subject: [PATCH 6.6 639/744] NFSv4: Fixup smatch warning for ambiguous return Date: Thu, 6 Jun 2024 16:05:11 +0200 Message-ID: <20240606131752.973114668@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131732.440653204@linuxfoundation.org> References: <20240606131732.440653204@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benjamin Coddington [ Upstream commit 37ffe06537af3e3ec212e7cbe941046fce0a822f ] Dan Carpenter reports smatch warning for nfs4_try_migration() when a memory allocation failure results in a zero return value. In this case, a transient allocation failure error will likely be retried the next time the server responds with NFS4ERR_MOVED. We can fixup the smatch warning with a small refactor: attempt all three allocations before testing and returning on a failure. Reported-by: Dan Carpenter Fixes: c3ed222745d9 ("NFSv4: Fix free of uninitialized nfs4_label on referral lookup.") Signed-off-by: Benjamin Coddington Reviewed-by: Dan Carpenter Reviewed-by: Chuck Lever Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs4state.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 9a5d911a7edc7..c95c50328ced8 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2117,6 +2117,7 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred { struct nfs_client *clp = server->nfs_client; struct nfs4_fs_locations *locations = NULL; + struct nfs_fattr *fattr; struct inode *inode; struct page *page; int status, result; @@ -2126,19 +2127,16 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred (unsigned long long)server->fsid.minor, clp->cl_hostname); - result = 0; page = alloc_page(GFP_KERNEL); locations = kmalloc(sizeof(struct nfs4_fs_locations), GFP_KERNEL); - if (page == NULL || locations == NULL) { - dprintk("<-- %s: no memory\n", __func__); - goto out; - } - locations->fattr = nfs_alloc_fattr(); - if (locations->fattr == NULL) { + fattr = nfs_alloc_fattr(); + if (page == NULL || locations == NULL || fattr == NULL) { dprintk("<-- %s: no memory\n", __func__); + result = 0; goto out; } + locations->fattr = fattr; inode = d_inode(server->super->s_root); result = nfs4_proc_get_locations(server, NFS_FH(inode), locations, page, cred); -- 2.43.0