Skip to contentSkip to conversation

fs: proc: Fix error checking for d_hash_and_lookup()

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

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yan Zhen

author
#0 lore raw

PATCH 1/1 fs: proc: 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().

---
 fs/proc/base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/base.c +1 -1
index f83d41bf155d..e08b36dd4766 100644
@@ -2123,7 +2123,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
 	ino_t ino = 1;
 
 	child = d_hash_and_lookup(dir, &qname);
-	if (!child) {
+	if (IS_ERR_OR_NULL(child)) {
 		DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
 		child = d_alloc_parallel(dir, &qname, &wq);
 		if (IS_ERR(child))
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Yan Zhen

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().

---

I distinctly remember having NAKed a patch like this either earlier this or last year. Procfs doesn't have a custom d_hash() function so d_hash_and_lookup() will never return an error pointer afaict.

maintainer
#2 lore raw
In reply to Yan Zhen
Quoted 3 lines · Yan Zhen

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().

Not for procfs it doesn't. Please, don't use that shite.