From: "Randy.Dunlap" <randy.dunlap@verizon.net>
To: linux-kernel@vger.kernel.org, torvalds@transmeta.com, leo@netlabs.net
Subject: [PATCH] reduce stack in cdrom/optcd.c
Date: Fri, 21 Mar 2003 22:51:52 -0800 [thread overview]
Message-ID: <3E7C0808.75B95FB7@verizon.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 149 bytes --]
Hi,
This reduces stack usage in drivers/cdrom/optcd.c by
dynamically allocating a large (> 2 KB) buffer.
Patch is to 2.5.65. Please apply.
~Randy
[-- Attachment #2: optcdrom-stack.patch --]
[-- Type: text/plain, Size: 1462 bytes --]
patch_name: optcdrom-stack.patch
patch_version: 2003-03-21.22:31:24
author: Randy.Dunlap <rddunlap@osdl.org>
description: reduce stack usage in drivers/cdrom/optcd::cdromread()
product: Linux
product_versions: 2.5.65
changelog: kmalloc() the large buffer
maintainer: Leo Spiekman <leo@netlabs.net>
diffstat: =
drivers/cdrom/optcd.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff -Naur ./drivers/cdrom/optcd.c%CDROM ./drivers/cdrom/optcd.c
--- ./drivers/cdrom/optcd.c%CDROM Mon Mar 17 13:43:49 2003
+++ ./drivers/cdrom/optcd.c Fri Mar 21 22:30:08 2003
@@ -1600,13 +1600,17 @@
static int cdromread(unsigned long arg, int blocksize, int cmd)
{
- int status;
+ int status, ret = 0;
struct cdrom_msf msf;
- char buf[CD_FRAMESIZE_RAWER];
+ char *buf;
if (copy_from_user(&msf, (void *) arg, sizeof msf))
return -EFAULT;
+ buf = kmalloc(CD_FRAMESIZE_RAWER, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
bin2bcd(&msf);
msf.cdmsf_min1 = 0;
msf.cdmsf_sec1 = 0;
@@ -1615,11 +1619,19 @@
DEBUG((DEBUG_VFS, "read cmd status 0x%x", status));
- if (!sleep_flag_low(FL_DTEN, SLEEP_TIMEOUT))
- return -EIO;
+ if (!sleep_flag_low(FL_DTEN, SLEEP_TIMEOUT)) {
+ ret = -EIO;
+ goto cdr_free;
+ }
+
fetch_data(buf, blocksize);
- return copy_to_user((void *)arg, &buf, blocksize) ? -EFAULT : 0;
+ if (copy_to_user((void *)arg, &buf, blocksize))
+ ret = -EFAULT;
+
+cdr_free:
+ kfree(buf);
+ return ret;
}
next reply other threads:[~2003-03-22 6:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-22 6:51 Randy.Dunlap [this message]
2003-03-22 20:43 ` [PATCH] reduce stack in cdrom/optcd.c Alan Cox
2003-03-22 20:19 ` Arjan van de Ven
2003-03-25 18:29 ` Jens Axboe
2003-03-25 18:43 ` Randy.Dunlap
-- strict thread matches above, loose matches on Subject: below --
2003-03-26 20:12 Randy.Dunlap
2003-03-27 6:54 ` Jens Axboe
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=3E7C0808.75B95FB7@verizon.net \
--to=randy.dunlap@verizon.net \
--cc=leo@netlabs.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.