Skip to content

Commit b7a87ad

Browse files
bentissJiri Kosina
authored andcommitted
HID: magicmouse: make transfer buffers DMA capable
Kernel v4.9 strictly enforces DMA capable buffers, so we need to remove buffers allocated on the stack. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 061232f commit b7a87ad

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

drivers/hid/hid-magicmouse.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ static int magicmouse_input_configured(struct hid_device *hdev,
493493
static int magicmouse_probe(struct hid_device *hdev,
494494
const struct hid_device_id *id)
495495
{
496-
__u8 feature[] = { 0xd7, 0x01 };
496+
const u8 feature[] = { 0xd7, 0x01 };
497+
u8 *buf;
497498
struct magicmouse_sc *msc;
498499
struct hid_report *report;
499500
int ret;
@@ -544,6 +545,12 @@ static int magicmouse_probe(struct hid_device *hdev,
544545
}
545546
report->size = 6;
546547

548+
buf = kmemdup(feature, sizeof(feature), GFP_KERNEL);
549+
if (!buf) {
550+
ret = -ENOMEM;
551+
goto err_stop_hw;
552+
}
553+
547554
/*
548555
* Some devices repond with 'invalid report id' when feature
549556
* report switching it into multitouch mode is sent to it.
@@ -552,8 +559,9 @@ static int magicmouse_probe(struct hid_device *hdev,
552559
* but there seems to be no other way of switching the mode.
553560
* Thus the super-ugly hacky success check below.
554561
*/
555-
ret = hid_hw_raw_request(hdev, feature[0], feature, sizeof(feature),
562+
ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(feature),
556563
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
564+
kfree(buf);
557565
if (ret != -EIO && ret != sizeof(feature)) {
558566
hid_err(hdev, "unable to request touch data (%d)\n", ret);
559567
goto err_stop_hw;

0 commit comments

Comments
 (0)