1
0
Fork 0

HID: intel_ish-hid: Stop using a static local buffer in get_report()

hid_ishtp_get_report() may be called by multiple callers at the same
time, causing trouble with the static local buffer used.

Also there is no reason to use a non stack buffer, the buffer is tiny
and ishtp_cl_send() copies its contents so the lifetime is not an
issue either.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
zero-colors
Hans de Goede 2018-04-14 17:06:45 +02:00 committed by Jiri Kosina
parent 37ba3c350e
commit 749ab300d4
1 changed files with 6 additions and 10 deletions

View File

@ -412,9 +412,7 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id,
{
struct ishtp_hid_data *hid_data = hid->driver_data;
struct ishtp_cl_data *client_data = hid_data->client_data;
static unsigned char buf[10];
unsigned int len;
struct hostif_msg_to_sensor *msg = (struct hostif_msg_to_sensor *)buf;
struct hostif_msg_to_sensor msg = {};
int rv;
int i;
@ -426,14 +424,11 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id,
return;
}
len = sizeof(struct hostif_msg_to_sensor);
memset(msg, 0, sizeof(struct hostif_msg_to_sensor));
msg->hdr.command = (report_type == HID_FEATURE_REPORT) ?
msg.hdr.command = (report_type == HID_FEATURE_REPORT) ?
HOSTIF_GET_FEATURE_REPORT : HOSTIF_GET_INPUT_REPORT;
for (i = 0; i < client_data->num_hid_devices; ++i) {
if (hid == client_data->hid_sensor_hubs[i]) {
msg->hdr.device_id =
msg.hdr.device_id =
client_data->hid_devices[i].dev_id;
break;
}
@ -442,8 +437,9 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id,
if (i == client_data->num_hid_devices)
return;
msg->report_id = report_id;
rv = ishtp_cl_send(client_data->hid_ishtp_cl, buf, len);
msg.report_id = report_id;
rv = ishtp_cl_send(client_data->hid_ishtp_cl, (uint8_t *)&msg,
sizeof(msg));
if (rv)
hid_ishtp_trace(client_data, "%s hid %p send failed\n",
__func__, hid);