Skip to contentSkip to conversation

sysfs: checking for NULL instead of ERR_PTR

PATCH In review Dan Carpenter 2 participants 3 messages Aug 25, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysfs: checking for NULL instead of ERR_PTR

d_path() returns an ERR_PTR and it doesn't return NULL.

fs/sysfs/file.c +1 -1
index 1b27b56..da3fefe 100644
@@ -340,7 +340,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	char *p;
 
 	p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
-	if (p)
+	if (!IS_ERR(p))
 		memmove(last_sysfs_file, p, strlen(p) + 1);
 
 	/* need attr_sd for attr and ops, its parent for kobj */
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

d_path() returns an ERR_PTR and it doesn't return NULL.

This is definitely a needed bug fix.

If we ever get ERR_PTR(-ENAMETOOLONG) and this case actually matters something is very wrong with sysfs, but that is another story.

Eric

Quoted 13 lines
fs/sysfs/file.c +1 -1
index 1b27b56..da3fefe 100644
@@ -340,7 +340,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	char *p;
 
 	p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
-	if (p)
+	if (!IS_ERR(p))
 		memmove(last_sysfs_file, p, strlen(p) + 1);
 
 	/* need attr_sd for attr and ops, its parent for kobj */
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

d_path() returns an ERR_PTR and it doesn't return NULL.

This is definitely a needed bug fix.

If we ever get ERR_PTR(-ENAMETOOLONG) and this case actually matters something is very wrong with sysfs, but that is another story.

Eric

Quoted 13 lines
fs/sysfs/file.c +1 -1
index 1b27b56..da3fefe 100644
@@ -340,7 +340,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
 	char *p;
 
 	p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
-	if (p)
+	if (!IS_ERR(p))
 		memmove(last_sysfs_file, p, strlen(p) + 1);
 
 	/* need attr_sd for attr and ops, its parent for kobj */