Commit 8c9e7aa1 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

[PATCH] USB: fix dma to stack in ti driver

you cannot use usb_bulk_msg() on buffers on the stack.
parent 2852f0fe
...@@ -161,7 +161,7 @@ tiglusb_read (struct file *filp, char __user *buf, size_t count, loff_t * f_pos) ...@@ -161,7 +161,7 @@ tiglusb_read (struct file *filp, char __user *buf, size_t count, loff_t * f_pos)
int bytes_to_read = 0; int bytes_to_read = 0;
int bytes_read = 0; int bytes_read = 0;
int result = 0; int result = 0;
char buffer[BULK_RCV_MAX]; char *buffer;
unsigned int pipe; unsigned int pipe;
if (*f_pos) if (*f_pos)
...@@ -173,6 +173,10 @@ tiglusb_read (struct file *filp, char __user *buf, size_t count, loff_t * f_pos) ...@@ -173,6 +173,10 @@ tiglusb_read (struct file *filp, char __user *buf, size_t count, loff_t * f_pos)
if (!s->dev) if (!s->dev)
return -EIO; return -EIO;
buffer = kmalloc(BULK_RCV_MAX, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
bytes_to_read = (count >= BULK_RCV_MAX) ? BULK_RCV_MAX : count; bytes_to_read = (count >= BULK_RCV_MAX) ? BULK_RCV_MAX : count;
pipe = usb_rcvbulkpipe (s->dev, 1); pipe = usb_rcvbulkpipe (s->dev, 1);
...@@ -203,6 +207,7 @@ tiglusb_read (struct file *filp, char __user *buf, size_t count, loff_t * f_pos) ...@@ -203,6 +207,7 @@ tiglusb_read (struct file *filp, char __user *buf, size_t count, loff_t * f_pos)
} }
out: out:
kfree(buffer);
return ret ? ret : bytes_read; return ret ? ret : bytes_read;
} }
...@@ -214,7 +219,7 @@ tiglusb_write (struct file *filp, const char __user *buf, size_t count, loff_t * ...@@ -214,7 +219,7 @@ tiglusb_write (struct file *filp, const char __user *buf, size_t count, loff_t *
int bytes_to_write = 0; int bytes_to_write = 0;
int bytes_written = 0; int bytes_written = 0;
int result = 0; int result = 0;
char buffer[BULK_SND_MAX]; char *buffer;
unsigned int pipe; unsigned int pipe;
if (*f_pos) if (*f_pos)
...@@ -226,6 +231,10 @@ tiglusb_write (struct file *filp, const char __user *buf, size_t count, loff_t * ...@@ -226,6 +231,10 @@ tiglusb_write (struct file *filp, const char __user *buf, size_t count, loff_t *
if (!s->dev) if (!s->dev)
return -EIO; return -EIO;
buffer = kmalloc(BULK_SND_MAX, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
bytes_to_write = (count >= BULK_SND_MAX) ? BULK_SND_MAX : count; bytes_to_write = (count >= BULK_SND_MAX) ? BULK_SND_MAX : count;
if (copy_from_user (buffer, buf, bytes_to_write)) { if (copy_from_user (buffer, buf, bytes_to_write)) {
ret = -EFAULT; ret = -EFAULT;
...@@ -258,6 +267,7 @@ tiglusb_write (struct file *filp, const char __user *buf, size_t count, loff_t * ...@@ -258,6 +267,7 @@ tiglusb_write (struct file *filp, const char __user *buf, size_t count, loff_t *
} }
out: out:
kfree(buffer);
return ret ? ret : bytes_written; return ret ? ret : bytes_written;
} }
......
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