[PATCH v2] NFS: idmap: handle zero return from nfs_idmap_get_key()

From: mdshahid03

Date: Thu Nov 12 2026 - 11:30:47 EST


From: Mohammad Shahid <mdshahid03@xxxxxxxxx>

nfs_idmap_get_key() can return zero, but nfs_idmap_lookup_name()
treats only negative values as errors.

Treat zero as an error to avoid reporting an unsuccessful lookup
as successful.

Signed-off-by: Mohammad Shahid <mdshahid03@xxxxxxxxx>
---
fs/nfs/nfs4idmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
index 06b193722660..8f5f0abf804d 100644
--- a/fs/nfs/nfs4idmap.c
+++ b/fs/nfs/nfs4idmap.c
@@ -353,7 +353,7 @@ static ssize_t nfs_idmap_lookup_name(__u32 id, const char *type, char *buf,

id_len = nfs_map_numeric_to_string(id, id_str, sizeof(id_str));
ret = nfs_idmap_get_key(id_str, id_len, type, buf, buflen, idmap);
- if (ret < 0)
+ if (ret <= 0)
return -EINVAL;
return ret;
}
--
2.43.0