Commit 749ab300 authored by Hans de Goede's avatar Hans de Goede Committed by Jiri Kosina

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: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 37ba3c35
...@@ -412,9 +412,7 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id, ...@@ -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_hid_data *hid_data = hid->driver_data;
struct ishtp_cl_data *client_data = hid_data->client_data; struct ishtp_cl_data *client_data = hid_data->client_data;
static unsigned char buf[10]; struct hostif_msg_to_sensor msg = {};
unsigned int len;
struct hostif_msg_to_sensor *msg = (struct hostif_msg_to_sensor *)buf;
int rv; int rv;
int i; int i;
...@@ -426,14 +424,11 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id, ...@@ -426,14 +424,11 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id,
return; return;
} }
len = sizeof(struct hostif_msg_to_sensor); msg.hdr.command = (report_type == HID_FEATURE_REPORT) ?
memset(msg, 0, sizeof(struct hostif_msg_to_sensor));
msg->hdr.command = (report_type == HID_FEATURE_REPORT) ?
HOSTIF_GET_FEATURE_REPORT : HOSTIF_GET_INPUT_REPORT; HOSTIF_GET_FEATURE_REPORT : HOSTIF_GET_INPUT_REPORT;
for (i = 0; i < client_data->num_hid_devices; ++i) { for (i = 0; i < client_data->num_hid_devices; ++i) {
if (hid == client_data->hid_sensor_hubs[i]) { if (hid == client_data->hid_sensor_hubs[i]) {
msg->hdr.device_id = msg.hdr.device_id =
client_data->hid_devices[i].dev_id; client_data->hid_devices[i].dev_id;
break; break;
} }
...@@ -442,8 +437,9 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id, ...@@ -442,8 +437,9 @@ void hid_ishtp_get_report(struct hid_device *hid, int report_id,
if (i == client_data->num_hid_devices) if (i == client_data->num_hid_devices)
return; return;
msg->report_id = report_id; msg.report_id = report_id;
rv = ishtp_cl_send(client_data->hid_ishtp_cl, buf, len); rv = ishtp_cl_send(client_data->hid_ishtp_cl, (uint8_t *)&msg,
sizeof(msg));
if (rv) if (rv)
hid_ishtp_trace(client_data, "%s hid %p send failed\n", hid_ishtp_trace(client_data, "%s hid %p send failed\n",
__func__, hid); __func__, hid);
......
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