Commit ea36ae09 authored by Josh Boyer's avatar Josh Boyer Committed by Jiri Kosina

HID: lenovo: Don't use stack variables for DMA buffers

The lenovo_send_cmd_cptkbd function uses a stack variable to submit
commands via hid_hw_raw_request.  Eventually this gets to the
usb_hcd_map_urb_for_dma function, which causes a warning to be thrown
if the CONFIG_DMA_API_DEBUG option is enabled.

Fix this by allocating a temporary buffer instead.

[jkosina@suse.cz: no need to NULL-initialize buf, spotted by Benjamin]
Reported-by: default avatarlejeczek <peljasz@yahoo.co.uk>
Signed-off-by: default avatarJosh Boyer <jwboyer@fedoraproject.org>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 972e6a99
...@@ -184,21 +184,31 @@ static int lenovo_send_cmd_cptkbd(struct hid_device *hdev, ...@@ -184,21 +184,31 @@ static int lenovo_send_cmd_cptkbd(struct hid_device *hdev,
unsigned char byte2, unsigned char byte3) unsigned char byte2, unsigned char byte3)
{ {
int ret; int ret;
unsigned char buf[] = {0x18, byte2, byte3}; unsigned char *buf;
buf = kzalloc(3, GFP_KERNEL);
if (!buf)
return -ENOMEM;
buf[0] = 0x18;
buf[1] = byte2;
buf[2] = byte3;
switch (hdev->product) { switch (hdev->product) {
case USB_DEVICE_ID_LENOVO_CUSBKBD: case USB_DEVICE_ID_LENOVO_CUSBKBD:
ret = hid_hw_raw_request(hdev, 0x13, buf, sizeof(buf), ret = hid_hw_raw_request(hdev, 0x13, buf, 3,
HID_FEATURE_REPORT, HID_REQ_SET_REPORT); HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
break; break;
case USB_DEVICE_ID_LENOVO_CBTKBD: case USB_DEVICE_ID_LENOVO_CBTKBD:
ret = hid_hw_output_report(hdev, buf, sizeof(buf)); ret = hid_hw_output_report(hdev, buf, 3);
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
kfree(buf);
return ret < 0 ? ret : 0; /* BT returns 0, USB returns sizeof(buf) */ return ret < 0 ? ret : 0; /* BT returns 0, USB returns sizeof(buf) */
} }
......
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