Messages in this thread Patch in this message | | | Date | Tue, 2 Nov 2004 02:46:58 -0600 (CST) | From | Milton Miller <> | Subject | sysfs backing store error path confusion |
| |
sysfs_new_dirent returns ERR_PTR(-ENOMEM) if kmalloc fails but the callers were expecting NULL.
Compile & link tested. (Yes, changing the callee would be a smaller change).
===== fs/sysfs/dir.c 1.24 vs edited ===== --- 1.24/fs/sysfs/dir.c 2004-11-01 21:46:46 +01:00 +++ edited/fs/sysfs/dir.c 2004-11-02 09:12:31 +01:00 @@ -55,8 +55,8 @@ int sysfs_make_dirent(struct sysfs_diren struct sysfs_dirent * sd; sd = sysfs_new_dirent(parent_sd, element); - if (!sd) - return -ENOMEM; + if (IS_ERR(sd)) + return PTR_ERR(sd); sd->s_mode = mode; sd->s_type = type; @@ -332,13 +332,18 @@ static int sysfs_dir_open(struct inode * { struct dentry * dentry = file->f_dentry; struct sysfs_dirent * parent_sd = dentry->d_fsdata; + struct sysfs_dirent * sd; down(&dentry->d_inode->i_sem); - file->private_data = sysfs_new_dirent(parent_sd, NULL); + sd = sysfs_new_dirent(parent_sd, NULL); up(&dentry->d_inode->i_sem); - return file->private_data ? 0 : -ENOMEM; + if (IS_ERR(sd)) + return PTR_ERR(sd); + + file->private_data = sd; + return 0; } static int sysfs_dir_close(struct inode *inode, struct file *file) - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |