linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: sensor-hub: Move the memset to sensor_hub_get_feature()
@ 2016-12-27 16:57 Srinivas Pandruvada
  2017-01-02 13:04 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2016-12-27 16:57 UTC (permalink / raw)
  To: jikos, jic23; +Cc: linux-input, linux-iio, Srinivas Pandruvada, Stable

While applying patch d443a0aa3a29: "HID: hid-sensor-hub: clear memory to
avoid random data", there was some issues in applying correct version of
the patch. This resulted in the breakage of sensor functions as all
request like power-up will be reset by the memset() in the function
sensor_hub_set_feature().
The reset of caller buffer should be in the function
sensor_hub_get_feature(), not in the sensor_hub_set_feature().

Fixes: d443a0aa3a29 ("HID: hid-sensor-hub: clear memory to avoid random data")
Cc: Stable <stable@vger.kernel.org> # 4.9+
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/hid/hid-sensor-hub.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 5c92522..4ef7337 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -212,7 +212,6 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 	__s32 value;
 	int ret = 0;
 
-	memset(buffer, 0, buffer_size);
 	mutex_lock(&data->mutex);
 	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
 	if (!report || (field_index >= report->maxfield)) {
@@ -256,6 +255,8 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 	int buffer_index = 0;
 	int i;
 
+	memset(buffer, 0, buffer_size);
+
 	mutex_lock(&data->mutex);
 	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
 	if (!report || (field_index >= report->maxfield) ||
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] HID: sensor-hub: Move the memset to sensor_hub_get_feature()
  2016-12-27 16:57 [PATCH] HID: sensor-hub: Move the memset to sensor_hub_get_feature() Srinivas Pandruvada
@ 2017-01-02 13:04 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2017-01-02 13:04 UTC (permalink / raw)
  To: Srinivas Pandruvada; +Cc: jic23, linux-input, linux-iio

On Tue, 27 Dec 2016, Srinivas Pandruvada wrote:

> While applying patch d443a0aa3a29: "HID: hid-sensor-hub: clear memory to
> avoid random data", there was some issues in applying correct version of
> the patch. This resulted in the breakage of sensor functions as all
> request like power-up will be reset by the memset() in the function
> sensor_hub_set_feature().
> The reset of caller buffer should be in the function
> sensor_hub_get_feature(), not in the sensor_hub_set_feature().
> 
> Fixes: d443a0aa3a29 ("HID: hid-sensor-hub: clear memory to avoid random data")
> Cc: Stable <stable@vger.kernel.org> # 4.9+
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Applied to for-4.10/upstream-fixes, and I'll be pushing that out to Linus 
shortly. Thanks for fixing my mistake.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-02 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-27 16:57 [PATCH] HID: sensor-hub: Move the memset to sensor_hub_get_feature() Srinivas Pandruvada
2017-01-02 13:04 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).