[PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller
From: Peng Fan (OSS)
Date: Fri Feb 27 2026 - 03:22:12 EST
From: Peng Fan <peng.fan@xxxxxxx>
nfs4_ff_alloc_deviceid_node() initialized 'ret' but never returned it,
triggering W=1:
fs/nfs/flexfilelayout/flexfilelayoutdev.c:56:9: error: variable 'ret'
set but not used [-Werror=unused-but-set-variable]
The function also returned NULL on error, dropping the specific errno
stored in 'ret'. Convert it to return ERR_PTR(ret) instead, and update
ff_layout_alloc_deviceid_node() to detect errors using IS_ERR().
This preserves the error code for callers and aligns the helper with
common ERR_PTR-returning allocation patterns. It also resolves the build
warning.
No functional change for success paths; improves error reporting.
Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 2 +-
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index f67773d52830d2ab4d12dd04caccc2077d4105e0..cd175204807600ff4e33ff769e03ef7ac700a6dc 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -2566,7 +2566,7 @@ ff_layout_alloc_deviceid_node(struct nfs_server *server,
struct nfs4_ff_layout_ds *dsaddr;
dsaddr = nfs4_ff_alloc_deviceid_node(server, pdev, gfp_flags);
- if (!dsaddr)
+ if (IS_ERR(dsaddr))
return NULL;
return &dsaddr->id_node;
}
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index c40395ae081429f315ccee6b73eafc742b4f01a4..9e36350b10fa84d5e2a2e6f25fce36ed504285ce 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -181,7 +181,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
kfree(new_ds);
dprintk("%s ERROR: returning %d\n", __func__, ret);
- return NULL;
+ return ERR_PTR(ret);
}
static void extend_ds_error(struct nfs4_ff_layout_ds_err *err,
--
2.37.1