public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	Tilman Schmidt <tilman@imap.cc>,
	Kay Sievers <kay.sievers@vrfy.org>
Subject: [PATCH 1/5] Driver core: fix show_uevent from taking up way too much stack
Date: Wed,  2 May 2007 19:11:29 -0700	[thread overview]
Message-ID: <11781582932668-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20070503020924.GB21316@kroah.com>

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>
---
 drivers/base/core.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8aa090d..59d9816 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;
 }
 
-- 
1.5.1.2


  reply	other threads:[~2007-05-03  2:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-03  2:09 [GIT PATCH] More core patches for 2.6.21 Greg KH
2007-05-03  2:11 ` Greg Kroah-Hartman [this message]
2007-05-03  2:11   ` [PATCH 2/5] platform: reorder platform_device_del Greg Kroah-Hartman
2007-05-03  2:11     ` [PATCH 3/5] DOC: Fix wrong identifier name in Documentation/driver-model/devres.txt Greg Kroah-Hartman
2007-05-03  2:11       ` [PATCH 4/5] sysfs: printk format warning Greg Kroah-Hartman
2007-05-03  2:11         ` [PATCH 5/5] remove "struct subsystem" as it is no longer needed Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11781582932668-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tilman@imap.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox