Skip to contentSkip to conversation

NFS: Fix a potential NULL dereference in nfs_get_client()

PATCH New Dan Carpenter 1 participant 1 message Jun 3, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFS: Fix a potential NULL dereference in nfs_get_client()

None of the callers are expecting NULL returns from nfs_get_client() so this code will lead to an Oops. It's better to return an error pointer. I expect that this is dead code so hopefully no one is affected.

Fixes 31434f496abb ("nfs: check hostname in nfs_get_client")
---
 fs/nfs/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/client.c +1 -1
index cfeaadf56bf0..330f65727c45 100644
@@ -406,7 +406,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init)
 
 	if (cl_init->hostname == NULL) {
 		WARN_ON(1);
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	/* see if the client already exists */
Signature · 1 line
2.30.2