public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: Jakob Kemi <jakob.kemi@post.utfors.se>
Subject: Large stack allocation in w9966 driver.
Date: Wed, 21 Jan 2004 19:45:59 +0000	[thread overview]
Message-ID: <20040121194559.GB9162@redhat.com> (raw)

Another large on-stack allocation. (This time around 2KB).

		Dave


diff -Nru a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
--- a/drivers/media/video/w9966.c	Wed Jan 21 19:10:44 2004
+++ b/drivers/media/video/w9966.c	Wed Jan 21 19:10:44 2004
@@ -875,6 +875,7 @@
 	unsigned char addr = 0xa0;	// ECP, read, CCD-transfer, 00000
 	unsigned char* dest = (unsigned char*)buf;
 	unsigned long dleft = count;
+	unsigned char *tbuf;
 	
 	// Why would anyone want more than this??
 	if (count > cam->width * cam->height * 2)
@@ -894,11 +895,14 @@
 		w9966_pdev_release(cam);
 		return -EFAULT;
 	}
-	
+
+	tbuf = kmalloc(W9966_RBUFFER, GFP_KERNEL);
+	if (tbuf == NULL)
+		return -ENOMEM;
+
 	while(dleft > 0)
 	{
 		unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft;
-		unsigned char tbuf[W9966_RBUFFER];
 	
 		if (parport_read(cam->pport, tbuf, tsize) < tsize) {
 			w9966_pdev_release(cam);
@@ -911,7 +915,8 @@
 		dest += tsize;
 		dleft -= tsize;
 	}
-	
+	kfree(tbuf);
+
 	w9966_wReg(cam, 0x01, 0x18);	// Disable capture
 	w9966_pdev_release(cam);
 

             reply	other threads:[~2004-01-21 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-21 19:45 Dave Jones [this message]
2004-01-21 20:01 ` Large stack allocation in w9966 driver Dave Jones

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=20040121194559.GB9162@redhat.com \
    --to=davej@redhat.com \
    --cc=jakob.kemi@post.utfors.se \
    --cc=linux-kernel@vger.kernel.org \
    /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