The zd1211rw driver uses unaligned stack buffer for USB control
message. But it might cause stack corruption on non-coherent
platform, such as MIPS. Use DMA-aware buffers for USB transfer.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
if (flags & REBOOT) {
u8 ret;
if (flags & REBOOT) {
u8 ret;
+ /* Use "DMA-aware" buffer. */
r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
USB_REQ_FIRMWARE_CONFIRM,
USB_DIR_IN | USB_TYPE_VENDOR,
r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
USB_REQ_FIRMWARE_CONFIRM,
USB_DIR_IN | USB_TYPE_VENDOR,
- 0, 0, &ret, sizeof(ret), 5000 /* ms */);
+ 0, 0, p, sizeof(ret), 5000 /* ms */);
if (r != sizeof(ret)) {
dev_err(&udev->dev,
"control request firmeware confirmation failed."
if (r != sizeof(ret)) {
dev_err(&udev->dev,
"control request firmeware confirmation failed."
r = -ENODEV;
goto error;
}
r = -ENODEV;
goto error;
}
if (ret & 0x80) {
dev_err(&udev->dev,
"Internal error while downloading."
if (ret & 0x80) {
dev_err(&udev->dev,
"Internal error while downloading."
{
int r;
struct usb_device *udev = zd_usb_to_usbdev(usb);
{
int r;
struct usb_device *udev = zd_usb_to_usbdev(usb);
+ /* Use "DMA-aware" buffer. */
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0,
r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0,
if (r < 0) {
dev_err(&udev->dev,
"read over firmware interface failed: %d\n", r);
if (r < 0) {
dev_err(&udev->dev,
"read over firmware interface failed: %d\n", r);
} else if (r != len) {
dev_err(&udev->dev,
"incomplete read over firmware interface: %d/%d\n",
r, len);
} else if (r != len) {
dev_err(&udev->dev,
"incomplete read over firmware interface: %d/%d\n",
r, len);
+ r = 0;
+ memcpy(data, buf, len);
+exit:
+ kfree(buf);
+ return r;
}
#define urb_dev(urb) (&(urb)->dev->dev)
}
#define urb_dev(urb) (&(urb)->dev->dev)