Commit 932fd605 authored by Andrew Morton's avatar Andrew Morton Committed by James Bottomley

[PATCH] kobject hotplug fixes

- allocated storage `envp' was being leaked on an error path

- kmalloc() returns void*, no need to cast it

- don't return 0 from a void-returning function

Greg has acked this patch.
parent a94538ff
...@@ -98,13 +98,13 @@ static void kset_hotplug(const char *action, struct kset *kset, ...@@ -98,13 +98,13 @@ static void kset_hotplug(const char *action, struct kset *kset,
struct kobject *kobj) struct kobject *kobj)
{ {
char *argv [3]; char *argv [3];
char **envp; char **envp = NULL;
char *buffer; char *buffer = NULL;
char *scratch; char *scratch;
int i = 0; int i = 0;
int retval; int retval;
int kobj_path_length; int kobj_path_length;
char *kobj_path; char *kobj_path = NULL;
char *name = NULL; char *name = NULL;
/* If the kset has a filter operation, call it. If it returns /* If the kset has a filter operation, call it. If it returns
...@@ -119,16 +119,14 @@ static void kset_hotplug(const char *action, struct kset *kset, ...@@ -119,16 +119,14 @@ static void kset_hotplug(const char *action, struct kset *kset,
if (!hotplug_path[0]) if (!hotplug_path[0])
return; return;
envp = (char **)kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); envp = kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL);
if (!envp) if (!envp)
return; return;
memset (envp, 0x00, NUM_ENVP * sizeof (char *)); memset (envp, 0x00, NUM_ENVP * sizeof (char *));
buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL); buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL);
if (!buffer) { if (!buffer)
kfree(envp); goto exit;
return;
}
if (kset->hotplug_ops->name) if (kset->hotplug_ops->name)
name = kset->hotplug_ops->name(kset, kobj); name = kset->hotplug_ops->name(kset, kobj);
...@@ -150,11 +148,8 @@ static void kset_hotplug(const char *action, struct kset *kset, ...@@ -150,11 +148,8 @@ static void kset_hotplug(const char *action, struct kset *kset,
kobj_path_length = get_kobj_path_length (kset, kobj); kobj_path_length = get_kobj_path_length (kset, kobj);
kobj_path = kmalloc (kobj_path_length, GFP_KERNEL); kobj_path = kmalloc (kobj_path_length, GFP_KERNEL);
if (!kobj_path) { if (!kobj_path)
kfree (buffer); goto exit;
kfree (envp);
return;
}
memset (kobj_path, 0x00, kobj_path_length); memset (kobj_path, 0x00, kobj_path_length);
fill_kobj_path (kset, kobj, kobj_path, kobj_path_length); fill_kobj_path (kset, kobj, kobj_path, kobj_path_length);
...@@ -181,15 +176,16 @@ static void kset_hotplug(const char *action, struct kset *kset, ...@@ -181,15 +176,16 @@ static void kset_hotplug(const char *action, struct kset *kset,
__FUNCTION__, retval); __FUNCTION__, retval);
exit: exit:
kfree (kobj_path); kfree(kobj_path);
kfree (buffer); kfree(buffer);
kfree(envp);
return; return;
} }
#else #else
static void kset_hotplug(const char *action, struct kset *kset, static void kset_hotplug(const char *action, struct kset *kset,
struct kobject *kobj) struct kobject *kobj)
{ {
return 0; return;
} }
#endif /* CONFIG_HOTPLUG */ #endif /* CONFIG_HOTPLUG */
......
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