From: Greg Kroah-Hartman Date: Wed, 2 May 2007 12:14:11 +0000 (+0200) Subject: Driver core: fix show_uevent from taking up way too much stack X-Git-Tag: v2.6.22-rc1~1038^2~4 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7308c81a8220ab68eebfadde37db881a2800064;p=linux-2.6 Driver core: fix show_uevent from taking up way too much stack 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 Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/core.c b/drivers/base/core.c index 8aa090da1c..59d9816c33 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -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; @@ -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, @@ -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; }