kernel/3.10: add '003-11-' prefix for patches backported from 3.11
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.10 / 003-11-008-hso-Fix-stack-corruption-on-some-architectures.patch
1 From e75dc677ff8d06ffa61bef6fee436227ae5440c6 Mon Sep 17 00:00:00 2001
2 From: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
3 Date: Wed, 21 Aug 2013 01:43:19 -0700
4 Subject: [PATCH] hso: Fix stack corruption on some architectures
5
6 commit e75dc677ff8d06ffa61bef6fee436227ae5440c6 upstream.
7
8 As Sergei Shtylyov explained in the #mipslinux IRC channel:
9 [Mon 2013-08-19 12:28:21 PM PDT] <headless> guys, are you sure it's not "DMA off stack" case?
10 [Mon 2013-08-19 12:28:35 PM PDT] <headless> it's a known stack corruptor on non-coherent arches
11 [Mon 2013-08-19 12:31:48 PM PDT] <DonkeyHotei> headless: for usb/ehci?
12 [Mon 2013-08-19 12:34:11 PM PDT] <DonkeyHotei> headless: explain
13 [Mon 2013-08-19 12:35:38 PM PDT] <headless> usb_control_msg() (or other such func) should not use buffer on stack. DMA from/to stack is prohibited
14 [Mon 2013-08-19 12:35:58 PM PDT] <headless> and EHCI uses DMA on control xfers (as well as all the others)
15
16 Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
17 Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 ---
20 drivers/net/usb/hso.c | 6 +++++-
21 1 file changed, 5 insertions(+), 1 deletion(-)
22
23 --- a/drivers/net/usb/hso.c
24 +++ b/drivers/net/usb/hso.c
25 @@ -2816,13 +2816,16 @@ exit:
26 static int hso_get_config_data(struct usb_interface *interface)
27 {
28 struct usb_device *usbdev = interface_to_usbdev(interface);
29 - u8 config_data[17];
30 + u8 *config_data = kmalloc(17, GFP_KERNEL);
31 u32 if_num = interface->altsetting->desc.bInterfaceNumber;
32 s32 result;
33
34 + if (!config_data)
35 + return -ENOMEM;
36 if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
37 0x86, 0xC0, 0, 0, config_data, 17,
38 USB_CTRL_SET_TIMEOUT) != 0x11) {
39 + kfree(config_data);
40 return -EIO;
41 }
42
43 @@ -2873,6 +2876,7 @@ static int hso_get_config_data(struct us
44 if (config_data[16] & 0x1)
45 result |= HSO_INFO_CRC_BUG;
46
47 + kfree(config_data);
48 return result;
49 }
50