aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristian Eggers <christian.eggers@kathrein.de>2009-01-21 15:56:24 -0500
committerDavid S. Miller <davem@davemloft.net>2009-01-21 15:56:24 -0500
commit6d317482944250228255bcbe97a95b7e7ad9a538 (patch)
tree699fd50b7ff360c0cb0c82cf1f28388d8996d461 /drivers
parent0b491eee46012772cbf029450d123e933c2e7940 (diff)
usb/mcs7830: Don't use buffers from stack for USB transfers
mcs7830_set_reg() and mcs7830_get_reg() are called with buffers from stack which must not be used directly for USB transfers. This causes corruption of the stack particulary on non x86 architectures because DMA may be used for these transfers. Signed-off-by: Christian Eggers <christian.eggers@kathrein.de> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/usb/mcs7830.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index 5385d66b306e..ced8f36ebd01 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -94,10 +94,18 @@ static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
94{ 94{
95 struct usb_device *xdev = dev->udev; 95 struct usb_device *xdev = dev->udev;
96 int ret; 96 int ret;
97 void *buffer;
98
99 buffer = kmalloc(size, GFP_NOIO);
100 if (buffer == NULL)
101 return -ENOMEM;
97 102
98 ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ, 103 ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ,
99 MCS7830_RD_BMREQ, 0x0000, index, data, 104 MCS7830_RD_BMREQ, 0x0000, index, buffer,
100 size, MCS7830_CTRL_TIMEOUT); 105 size, MCS7830_CTRL_TIMEOUT);
106 memcpy(data, buffer, size);
107 kfree(buffer);
108
101 return ret; 109 return ret;
102} 110}
103 111
@@ -105,10 +113,18 @@ static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, void *data)
105{ 113{
106 struct usb_device *xdev = dev->udev; 114 struct usb_device *xdev = dev->udev;
107 int ret; 115 int ret;
116 void *buffer;
117
118 buffer = kmalloc(size, GFP_NOIO);
119 if (buffer == NULL)
120 return -ENOMEM;
121
122 memcpy(buffer, data, size);
108 123
109 ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ, 124 ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ,
110 MCS7830_WR_BMREQ, 0x0000, index, data, 125 MCS7830_WR_BMREQ, 0x0000, index, buffer,
111 size, MCS7830_CTRL_TIMEOUT); 126 size, MCS7830_CTRL_TIMEOUT);
127 kfree(buffer);
112 return ret; 128 return ret;
113} 129}
114 130