aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAndrew Morton <akpm@digeo.com>2003-04-12 12:54:10 -0700
committerJames Bottomley <jejb@raven.il.steeleye.com>2003-04-12 12:54:10 -0700
commit932fd6059adff1e59b2d2ac074f90786c33babe5 (patch)
tree6410627aa253851a812a20d8ae49897b11cb8abd /lib
parenta94538ff4eda8447e6b9d8f3908b96cee11cc8d7 (diff)
downloadhistory-932fd6059adff1e59b2d2ac074f90786c33babe5.tar.gz
[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.
Diffstat (limited to 'lib')
-rw-r--r--lib/kobject.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 2f8c225b701029..6ea750e95c5655 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -98,13 +98,13 @@ static void kset_hotplug(const char *action, struct kset *kset,
struct kobject *kobj)
{
char *argv [3];
- char **envp;
- char *buffer;
+ char **envp = NULL;
+ char *buffer = NULL;
char *scratch;
int i = 0;
int retval;
int kobj_path_length;
- char *kobj_path;
+ char *kobj_path = NULL;
char *name = NULL;
/* 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,
if (!hotplug_path[0])
return;
- envp = (char **)kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL);
+ envp = kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL);
if (!envp)
return;
memset (envp, 0x00, NUM_ENVP * sizeof (char *));
buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL);
- if (!buffer) {
- kfree(envp);
- return;
- }
+ if (!buffer)
+ goto exit;
if (kset->hotplug_ops->name)
name = kset->hotplug_ops->name(kset, kobj);
@@ -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 = kmalloc (kobj_path_length, GFP_KERNEL);
- if (!kobj_path) {
- kfree (buffer);
- kfree (envp);
- return;
- }
+ if (!kobj_path)
+ goto exit;
memset (kobj_path, 0x00, 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,
__FUNCTION__, retval);
exit:
- kfree (kobj_path);
- kfree (buffer);
+ kfree(kobj_path);
+ kfree(buffer);
+ kfree(envp);
return;
}
#else
static void kset_hotplug(const char *action, struct kset *kset,
struct kobject *kobj)
{
- return 0;
+ return;
}
#endif /* CONFIG_HOTPLUG */