Skip to contentSkip to conversation

sunrpc: Fix error checking for d_hash_and_lookup()

PATCH Superseded Yan Zhen 2 participants 2 messages Aug 26, 2024

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yan Zhen

author
#0 lore raw

PATCH v2 1/1 sunrpc: Fix error checking for d_hash_and_lookup()

The d_hash_and_lookup() function returns either an error pointer or NULL.

It might be more appropriate to check error using IS_ERR_OR_NULL().

Fixes b7ade38165ca ("sunrpc: fixed rollback in rpc_gssd_dummy_populate()")

---

Changes in v2:
- Providing a "fixes" tag blaming the commit.

 net/sunrpc/rpc_pipe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/rpc_pipe.c +2 -2
index 910a5d850d04..fd03dd46b1f2 100644
@@ -1306,7 +1306,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
 
 	/* We should never get this far if "gssd" doesn't exist */
 	gssd_dentry = d_hash_and_lookup(root, &q);
-	if (!gssd_dentry)
+	if (IS_ERR_OR_NULL(gssd_dentry))
 		return ERR_PTR(-ENOENT);
 
 	ret = rpc_populate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1, NULL);
@@ -1318,7 +1318,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
 	q.name = gssd_dummy_clnt_dir[0].name;
 	q.len = strlen(gssd_dummy_clnt_dir[0].name);
 	clnt_dentry = d_hash_and_lookup(gssd_dentry, &q);
-	if (!clnt_dentry) {
+	if (IS_ERR_OR_NULL(clnt_dentry)) {
 		__rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1);
 		pipe_dentry = ERR_PTR(-ENOENT);
 		goto out;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Mon, Aug 26, 2024 at 01:25:09PM CEST, [email protected] wrote:

The d_hash_and_lookup() function returns either an error pointer or NULL.

It might be more appropriate to check error using IS_ERR_OR_NULL().

Fixes b7ade38165ca ("sunrpc: fixed rollback in rpc_gssd_dummy_populate()")

That certainly does not look correct.

Quoted 35 lines

---

Changes in v2:
- Providing a "fixes" tag blaming the commit.

net/sunrpc/rpc_pipe.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/rpc_pipe.c +2 -2
index 910a5d850d04..fd03dd46b1f2 100644
@@ -1306,7 +1306,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
 
 	/* We should never get this far if "gssd" doesn't exist */
 	gssd_dentry = d_hash_and_lookup(root, &q);
-	if (!gssd_dentry)
+	if (IS_ERR_OR_NULL(gssd_dentry))
 		return ERR_PTR(-ENOENT);
 
 	ret = rpc_populate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1, NULL);
@@ -1318,7 +1318,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data)
 	q.name = gssd_dummy_clnt_dir[0].name;
 	q.len = strlen(gssd_dummy_clnt_dir[0].name);
 	clnt_dentry = d_hash_and_lookup(gssd_dentry, &q);
-	if (!clnt_dentry) {
+	if (IS_ERR_OR_NULL(clnt_dentry)) {
 		__rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1);
 		pipe_dentry = ERR_PTR(-ENOENT);
 		goto out;
Signature · 1 line
2.34.1