public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank Seidel <fseidel@suse.de>
To: linux kernel <linux-kernel@vger.kernel.org>
Cc: akpm@linux-foundation.org, Ankita Garg <ankita@in.ibm.com>,
	Adrian Bunk <bunk@kernel.org>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	Frank Seidel <fseidel@suse.de>, Frank Seidel <frank@f-seidel.de>,
	kernalert.de@gmail.com
Subject: [PATCH] lkdtm: reduce stack size
Date: Sun, 01 Mar 2009 21:00:14 +0100	[thread overview]
Message-ID: <49AAE94E.8080308@suse.de> (raw)

From: Frank Seidel <frank@f-seidel.de>

Reduce stack memory footprint of lkdtm
(recursive_loop). From 1024 bytes on i386 down
to <10.

Signed-off-by: Frank Seidel <frank@f-seidel.de>
---
 drivers/misc/lkdtm.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -225,14 +225,24 @@ static int lkdtm_parse_commandline(void)
 
 static int recursive_loop(int a)
 {
-	char buf[1024];
+	char *buf;
+	int ret;
+
+	buf = kmalloc(1024, GFP_KERNEL);
+	if (!buf) {
+		printk(KERN_ERR "lkdtm : couldn't allocate buffer\n");
+		return -ENOMEM;
+	}
 
 	memset(buf,0xFF,1024);
 	recur_count--;
 	if (!recur_count)
-		return 0;
+		ret = 0;
 	else
-        	return recursive_loop(a);
+		ret = recursive_loop(a);
+
+	kfree(buf);
+	return ret;
 }
 
 void lkdtm_handler(void)

             reply	other threads:[~2009-03-01 20:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-01 20:00 Frank Seidel [this message]
2009-03-02  4:11 ` [PATCH] lkdtm: reduce stack size Ankita Garg
2009-03-02  8:10   ` Frank Seidel
2009-03-02  9:51   ` Bernd Petrovitsch
2009-03-02 10:12     ` Ankita Garg

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=49AAE94E.8080308@suse.de \
    --to=fseidel@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=ankita@in.ibm.com \
    --cc=bunk@kernel.org \
    --cc=frank@f-seidel.de \
    --cc=kernalert.de@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    /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