Skip to contentSkip to conversation

fs: Fix error checking for d_hash_and_lookup()

PATCH In review Wang Ming 2 participants 2 messages Jul 13, 2023 VFS

lore
Share & tools
lore

Wang Ming

author
#0 lore raw

PATCH 1/1 fs: Fix error checking for d_hash_and_lookup()

In case of failure, debugfs_create_dir() returns NULL or an error pointer. Most incorrect error checks were fixed, but the one in d_add_ci() was forgotten.

Fixes d9171b934526 ("parallel lookups machinery, part 4 (and last)")
---
 fs/dcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dcache.c +1 -1
index 52e6d5fdab6b..2f03e275d2e0 100644
@@ -2220,7 +2220,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
 	 * if not go ahead and create it now.
 	 */
 	found = d_hash_and_lookup(dentry->d_parent, name);
-	if (found) {
+	if (!IS_ERR_OR_NULL(found)) {
 		iput(inode);
 		return found;
 	}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 1 line · Wang Ming

In case of failure, debugfs_create_dir() returns NULL or an error

What on earth does debugfs_create_dir() have to do with this?

Quoted 14 lines

pointer. Most incorrect error checks were fixed, but the one in d_add_ci() was forgotten.

Fixes d9171b934526 ("parallel lookups machinery, part 4 (and last)")
---
 fs/dcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dcache.c +0 -0
index 52e6d5fdab6b..2f03e275d2e0 100644

fs/dcache.c struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, · line 2223

Quoted 5 lines
fs/dcache.c +1 -1
@@ -2220,7 +2220,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
 	 * if not go ahead and create it now.
 	 */
 	found = d_hash_and_lookup(dentry->d_parent, name);
-	if (found) {
+	if (!IS_ERR_OR_NULL(found)) {

I don't understand.

If d_hash_and_lookup() fails due to custom hash function failure then the old code bubbles that upwards. You're changing that so that it now adds a new dentry under the generic hash. That can't possibly be correct.