Commit 45a522ed authored by Randy Dunlap's avatar Randy Dunlap Committed by Greg Kroah-Hartman

[PATCH] reduce stack in cdrom/optcd.c

This reduces stack usage in drivers/cdrom/optcd.c by
dynamically allocating a large (> 2 KB) buffer.
parent 0dab5c04
...@@ -1600,13 +1600,17 @@ static int cdromsubchnl(unsigned long arg) ...@@ -1600,13 +1600,17 @@ static int cdromsubchnl(unsigned long arg)
static int cdromread(unsigned long arg, int blocksize, int cmd) static int cdromread(unsigned long arg, int blocksize, int cmd)
{ {
int status; int status, ret = 0;
struct cdrom_msf msf; struct cdrom_msf msf;
char buf[CD_FRAMESIZE_RAWER]; char *buf;
if (copy_from_user(&msf, (void *) arg, sizeof msf)) if (copy_from_user(&msf, (void *) arg, sizeof msf))
return -EFAULT; return -EFAULT;
buf = kmalloc(CD_FRAMESIZE_RAWER, GFP_KERNEL);
if (!buf)
return -ENOMEM;
bin2bcd(&msf); bin2bcd(&msf);
msf.cdmsf_min1 = 0; msf.cdmsf_min1 = 0;
msf.cdmsf_sec1 = 0; msf.cdmsf_sec1 = 0;
...@@ -1615,11 +1619,19 @@ static int cdromread(unsigned long arg, int blocksize, int cmd) ...@@ -1615,11 +1619,19 @@ static int cdromread(unsigned long arg, int blocksize, int cmd)
DEBUG((DEBUG_VFS, "read cmd status 0x%x", status)); DEBUG((DEBUG_VFS, "read cmd status 0x%x", status));
if (!sleep_flag_low(FL_DTEN, SLEEP_TIMEOUT)) if (!sleep_flag_low(FL_DTEN, SLEEP_TIMEOUT)) {
return -EIO; ret = -EIO;
goto cdr_free;
}
fetch_data(buf, blocksize); 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;
} }
......
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