public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.24-rc7 1/2] sysfs: make sysfs_lookup() return ERR_PTR(-ENOENT) on failed lookup
@ 2008-01-16  3:06 Tejun Heo
  2008-01-16  3:10 ` [PATCH 2.6.24-rc7 2/2] sysfs: fix bugs in sysfs_rename/move_dir() Tejun Heo
  0 siblings, 1 reply; 8+ messages in thread
From: Tejun Heo @ 2008-01-16  3:06 UTC (permalink / raw)
  To: Linus Torvalds, Linux Kernel
  Cc: Al Viro, Gabor Gombas, Greg KH, Dave Young, bluez-devel

sysfs tries to keep dcache a strict subset of sysfs_dirent tree by
shooting down dentries when a node is removed, that is, no negative
dentry for sysfs.  However, the lookup function returned NULL and thus
created negative dentries when the target node didn't exist.

Make sysfs_lookup() return ERR_PTR(-ENOENT) on lookup failure.  This
fixes the NULL dereference bug in sysfs_get_dentry() discovered by
bluetooth rfcomm device moving around.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
 fs/sysfs/dir.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: work/fs/sysfs/dir.c
===================================================================
--- work.orig/fs/sysfs/dir.c
+++ work/fs/sysfs/dir.c
@@ -678,8 +678,10 @@ static struct dentry * sysfs_lookup(stru
 	sd = sysfs_find_dirent(parent_sd, dentry->d_name.name);
 
 	/* no such entry */
-	if (!sd)
+	if (!sd) {
+		ret = ERR_PTR(-ENOENT);
 		goto out_unlock;
+	}
 
 	/* attach dentry and inode */
 	inode = sysfs_get_inode(sd);

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-01-17  4:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-16  3:06 [PATCH 2.6.24-rc7 1/2] sysfs: make sysfs_lookup() return ERR_PTR(-ENOENT) on failed lookup Tejun Heo
2008-01-16  3:10 ` [PATCH 2.6.24-rc7 2/2] sysfs: fix bugs in sysfs_rename/move_dir() Tejun Heo
2008-01-16  3:41   ` Linus Torvalds
2008-01-16  3:52     ` Al Viro
2008-01-16  7:23       ` Tejun Heo
2008-01-17  4:22         ` Al Viro
2008-01-16  6:47     ` Tejun Heo
2008-01-16  8:20       ` Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox