Skip to contentSkip to conversation

inotify: check for NULL inode in inotify_d_instantiate

PATCH In review Arnd Bergmann 2 participants 2 messages Apr 7, 2006 – Apr 8, 2006 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 inotify: check for NULL inode in inotify_d_instantiate

The spufs file system creates files in a directory before instantiating the directory itself, which causes a NULL pointer access in inotify_d_instantiate since c32ccd87bfd1414b0aabfcd8dbc7539ad23bcbaa.

I'd like to keep this behavior since it means that the user will not have access to files in the directory before I know that I succeed in creating everything in it. This patch adds a simple check for the inode to keep that working.

---

fs/inotify.c +1 -1
index 367c487..1f50302 100644
@@ -538,7 +538,7 @@ void inotify_d_instantiate(struct dentry
 	WARN_ON(entry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
 	spin_lock(&entry->d_lock);
 	parent = entry->d_parent;
-	if (inotify_inode_watched(parent->d_inode))
+	if (parent->d_inode && inotify_inode_watched(parent->d_inode))
 		entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
 	spin_unlock(&entry->d_lock);
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

The spufs file system creates files in a directory before instantiating the directory itself, which causes a NULL pointer access in inotify_d_instantiate since c32ccd87bfd1414b0aabfcd8dbc7539ad23bcbaa.

I'd like to keep this behavior since it means that the user will not have access to files in the directory before I know that I succeed in creating everything in it. This patch adds a simple check for the inode to keep that working.

If this were not the correct thing to do, it is not the business of c32ccd87bfd1414b0aabfcd8dbc7539ad23bcbaa to prevent it. Thanks.

Quoted 17 lines

---

fs/inotify.c +1 -1
index 367c487..1f50302 100644
@@ -538,7 +538,7 @@ void inotify_d_instantiate(struct dentry
 	WARN_ON(entry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
 	spin_lock(&entry->d_lock);
 	parent = entry->d_parent;
-	if (inotify_inode_watched(parent->d_inode))
+	if (parent->d_inode && inotify_inode_watched(parent->d_inode))
 		entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
 	spin_unlock(&entry->d_lock);
 }