Skip to content

Commit

Permalink
Driver core: fix show_uevent from taking up way too much stack
Browse files Browse the repository at this point in the history
Declaring an array of PAGE_SIZE does bad things for people running with
4k stacks...

Thanks to Tilman Schmidt for tracking this down.

Cc: Tilman Schmidt <tilman@imap.cc>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed May 3, 2007
1 parent dc87c39 commit c7308c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
struct kobject *top_kobj;
struct kset *kset;
char *envp[32];
char data[PAGE_SIZE];
char *data = NULL;
char *pos;
int i;
size_t count = 0;
Expand All @@ -276,6 +276,10 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
if (!kset->uevent_ops->filter(kset, &dev->kobj))
goto out;

data = (char *)get_zeroed_page(GFP_KERNEL);
if (!data)
return -ENOMEM;

/* let the kset specific function add its keys */
pos = data;
retval = kset->uevent_ops->uevent(kset, &dev->kobj,
Expand All @@ -290,6 +294,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
count += sprintf(pos, "%s\n", envp[i]);
}
out:
free_page((unsigned long)data);
return count;
}

Expand Down

0 comments on commit c7308c8

Please sign in to comment.