Commit 2cb7ab3e authored by Milton D. Miller II's avatar Milton D. Miller II Committed by Greg Kroah-Hartman

[PATCH] fix sysfs backing store error path confusion

On Nov 3, 2004, at 3:42 PM, Greg KH wrote:

|On Tue, Nov 02, 2004 at 10:03:34AM -0600, Maneesh Soni wrote:
||On Tue, Nov 02, 2004 at 02:46:58AM -0600, Milton Miller wrote:
|||sysfs_new_dirent returns ERR_PTR(-ENOMEM) if kmalloc fails but the callers
|||were expecting NULL.
||
||Thanks for spotting this. But as you said, I will prefer to change the callee.
||How about this patch?
..
||-		return -ENOMEM;
||+		return NULL;
|
|Actually, this needs to be a 0, not NULL, otherwise the compiler
|complains with a warning.  I've fixed it up and applied it.
|
|thanks,
|
|greg k-h

I wondered why greg thought the type was wrong.   After it was merged I
realized that the wrong function was changed.  Here's an attempt to fix
both errors.
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 05997f16
...@@ -38,7 +38,7 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd, ...@@ -38,7 +38,7 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
sd = kmalloc(sizeof(*sd), GFP_KERNEL); sd = kmalloc(sizeof(*sd), GFP_KERNEL);
if (!sd) if (!sd)
return ERR_PTR(-ENOMEM); return NULL;
memset(sd, 0, sizeof(*sd)); memset(sd, 0, sizeof(*sd));
atomic_set(&sd->s_count, 1); atomic_set(&sd->s_count, 1);
...@@ -56,7 +56,7 @@ int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry, ...@@ -56,7 +56,7 @@ int sysfs_make_dirent(struct sysfs_dirent * parent_sd, struct dentry * dentry,
sd = sysfs_new_dirent(parent_sd, element); sd = sysfs_new_dirent(parent_sd, element);
if (!sd) if (!sd)
return 0; return -ENOMEMurn -ENOMEM;
sd->s_mode = mode; sd->s_mode = mode;
sd->s_type = type; sd->s_type = type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment