Skip to content

Commit 061232f

Browse files
bentissJiri Kosina
authored andcommitted
HID: lg: make transfer buffers DMA capable
Kernel v4.9 strictly enforces DMA capable buffers, so we need to remove buffers allocated on the stack. [jkosina@suse.cz: fix up second usage of hid_hw_raw_request(), spotted by 0day build bot] Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 1ffb3c4 commit 061232f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/hid/hid-lg.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,16 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
756756

757757
/* Setup wireless link with Logitech Wii wheel */
758758
if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) {
759-
unsigned char buf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
759+
const unsigned char cbuf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
760+
u8 *buf = kmemdup(cbuf, sizeof(cbuf), GFP_KERNEL);
760761

761-
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
762-
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
762+
if (!buf) {
763+
ret = -ENOMEM;
764+
goto err_free;
765+
}
763766

767+
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
768+
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
764769
if (ret >= 0) {
765770
/* insert a little delay of 10 jiffies ~ 40ms */
766771
wait_queue_head_t wait;
@@ -772,9 +777,10 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
772777
buf[1] = 0xB2;
773778
get_random_bytes(&buf[2], 2);
774779

775-
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
780+
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(cbuf),
776781
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
777782
}
783+
kfree(buf);
778784
}
779785

780786
if (drv_data->quirks & LG_FF)

0 commit comments

Comments
 (0)