Commit 7ac8e36e authored by Dave Jones's avatar Dave Jones Committed by Linus Torvalds

[PATCH] Reduce stack usage in w9966 driver.

2KB onstack allocation. Nasty.
parent fd036b30
...@@ -875,6 +875,7 @@ static ssize_t w9966_v4l_read(struct file *file, char *buf, ...@@ -875,6 +875,7 @@ static ssize_t w9966_v4l_read(struct file *file, char *buf,
unsigned char addr = 0xa0; // ECP, read, CCD-transfer, 00000 unsigned char addr = 0xa0; // ECP, read, CCD-transfer, 00000
unsigned char* dest = (unsigned char*)buf; unsigned char* dest = (unsigned char*)buf;
unsigned long dleft = count; unsigned long dleft = count;
unsigned char *tbuf;
// Why would anyone want more than this?? // Why would anyone want more than this??
if (count > cam->width * cam->height * 2) if (count > cam->width * cam->height * 2)
...@@ -894,25 +895,33 @@ static ssize_t w9966_v4l_read(struct file *file, char *buf, ...@@ -894,25 +895,33 @@ static ssize_t w9966_v4l_read(struct file *file, char *buf,
w9966_pdev_release(cam); w9966_pdev_release(cam);
return -EFAULT; return -EFAULT;
} }
tbuf = kmalloc(W9966_RBUFFER, GFP_KERNEL);
if (tbuf == NULL) {
count = -ENOMEM;
goto out;
}
while(dleft > 0) while(dleft > 0)
{ {
unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft; unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft;
unsigned char tbuf[W9966_RBUFFER];
if (parport_read(cam->pport, tbuf, tsize) < tsize) { if (parport_read(cam->pport, tbuf, tsize) < tsize) {
w9966_pdev_release(cam); count = -EFAULT;
return -EFAULT; goto out;
} }
if (copy_to_user(dest, tbuf, tsize) != 0) { if (copy_to_user(dest, tbuf, tsize) != 0) {
w9966_pdev_release(cam); count = -EFAULT;
return -EFAULT; goto out;
} }
dest += tsize; dest += tsize;
dleft -= tsize; dleft -= tsize;
} }
w9966_wReg(cam, 0x01, 0x18); // Disable capture w9966_wReg(cam, 0x01, 0x18); // Disable capture
out:
kfree(tbuf);
w9966_pdev_release(cam); w9966_pdev_release(cam);
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment