Commit 517828a8 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Gustavo Padovan

Bluetooth: ath3k: don't use stack memory for DMA

Memory allocated by vmalloc (including stack) can not be used for DMA,
i.e. data pointer on usb_control_msg() should not point to stack memory.

Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=977558Reported-and-tested-by: default avatarAndy Lawrence <dr.diesel@gmail.com>
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 84eb2ae1
...@@ -195,24 +195,44 @@ static int ath3k_load_firmware(struct usb_device *udev, ...@@ -195,24 +195,44 @@ static int ath3k_load_firmware(struct usb_device *udev,
static int ath3k_get_state(struct usb_device *udev, unsigned char *state) static int ath3k_get_state(struct usb_device *udev, unsigned char *state)
{ {
int pipe = 0; int ret, pipe = 0;
char *buf;
buf = kmalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;
pipe = usb_rcvctrlpipe(udev, 0); pipe = usb_rcvctrlpipe(udev, 0);
return usb_control_msg(udev, pipe, ATH3K_GETSTATE, ret = usb_control_msg(udev, pipe, ATH3K_GETSTATE,
USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
state, 0x01, USB_CTRL_SET_TIMEOUT); buf, sizeof(*buf), USB_CTRL_SET_TIMEOUT);
*state = *buf;
kfree(buf);
return ret;
} }
static int ath3k_get_version(struct usb_device *udev, static int ath3k_get_version(struct usb_device *udev,
struct ath3k_version *version) struct ath3k_version *version)
{ {
int pipe = 0; int ret, pipe = 0;
struct ath3k_version *buf;
const int size = sizeof(*buf);
buf = kmalloc(size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
pipe = usb_rcvctrlpipe(udev, 0); pipe = usb_rcvctrlpipe(udev, 0);
return usb_control_msg(udev, pipe, ATH3K_GETVERSION, ret = usb_control_msg(udev, pipe, ATH3K_GETVERSION,
USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, version, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
sizeof(struct ath3k_version), buf, size, USB_CTRL_SET_TIMEOUT);
USB_CTRL_SET_TIMEOUT);
memcpy(version, buf, size);
kfree(buf);
return ret;
} }
static int ath3k_load_fwfile(struct usb_device *udev, static int ath3k_load_fwfile(struct usb_device *udev,
......
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