linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hid: hid-sensor-hub: clear memory to avoid random data
@ 2016-11-11  0:58 Song Hongyan
  2016-11-12 14:43 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Song Hongyan @ 2016-11-11  0:58 UTC (permalink / raw)
  To: linux-input, linux-iio; +Cc: jikos, jic23, srinivas.pandruvada, Song Hongyan

Initialize user buffer with 0s. This will avoid random data in the buffer,
when the user buffer size is bigger than the actual report size.

Signed-off-by: Song Hongyan <hongyan.song@intel.com>
---
Changes in v2:
    -clear memory in get_feature() instead of set_feature()

 drivers/hid/hid-sensor-hub.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 658a607..b74d954 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -252,6 +252,7 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 	int report_size;
 	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) ||
-- 
1.9.1


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

* Re: [PATCH v2] hid: hid-sensor-hub: clear memory to avoid random data
  2016-11-11  0:58 [PATCH v2] hid: hid-sensor-hub: clear memory to avoid random data Song Hongyan
@ 2016-11-12 14:43 ` Jonathan Cameron
  2016-11-13 14:45   ` Pandruvada, Srinivas
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2016-11-12 14:43 UTC (permalink / raw)
  To: Song Hongyan, linux-input, linux-iio; +Cc: jikos, srinivas.pandruvada

On 11/11/16 00:58, Song Hongyan wrote:
> Initialize user buffer with 0s. This will avoid random data in the buffer,
> when the user buffer size is bigger than the actual report size.
> 
> Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Please describe the result of this bug in the description.
Why does it matter?

Without that info, it's hard to judge what path this should take
into mainline or whether the fix needs to be marked for stable.

Thanks,

Jonathan
> ---
> Changes in v2:
>     -clear memory in get_feature() instead of set_feature()
> 
>  drivers/hid/hid-sensor-hub.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 658a607..b74d954 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -252,6 +252,7 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>  	int report_size;
>  	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) ||
> 


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

* Re: [PATCH v2] hid: hid-sensor-hub: clear memory to avoid random data
  2016-11-12 14:43 ` Jonathan Cameron
@ 2016-11-13 14:45   ` Pandruvada, Srinivas
  0 siblings, 0 replies; 3+ messages in thread
From: Pandruvada, Srinivas @ 2016-11-13 14:45 UTC (permalink / raw)
  To: linux-input@vger.kernel.org, Song, Hongyan,
	linux-iio@vger.kernel.org, jic23@kernel.org
  Cc: jikos@kernel.org

T24gU2F0LCAyMDE2LTExLTEyIGF0IDE0OjQzICswMDAwLCBKb25hdGhhbiBDYW1lcm9uIHdyb3Rl
Og0KPiBPbiAxMS8xMS8xNiAwMDo1OCwgU29uZyBIb25neWFuIHdyb3RlOg0KPiA+IA0KPiA+IElu
aXRpYWxpemUgdXNlciBidWZmZXIgd2l0aCAwcy4gVGhpcyB3aWxsIGF2b2lkIHJhbmRvbSBkYXRh
IGluIHRoZQ0KPiA+IGJ1ZmZlciwNCj4gPiB3aGVuIHRoZSB1c2VyIGJ1ZmZlciBzaXplIGlzIGJp
Z2dlciB0aGFuIH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50IHNlbnNvcl9odWJfZ2V0X2ZlYXR1cmUoc3RydWN0DQo+ID4gaGlkX3NlbnNvcl9odWJf
ZGV2aWNlICpoc2RldiwgdTMyIHJlcG9ydF9pZCwNCj4gPiDCoAlpbnQgcmVwb3J0X3NpemU7DQo+
ID4gwqAJaW50IHJldCA9IDA7DQo+ID4gwqANCj4gPiArCW1lbXNldChidWZmZXIsIDAsIGJ1ZmZl
cl9zaXplKTsNCj4gPiDCoAltdXRleF9sb2NrKCZkYXRhLT5tdXRleCk7DQo+ID4gwqAJcmVwb3J0
ID0gc2Vuc29yX2h1Yl9yZXBvcnQocmVwb3J0X2lkLCBoc2Rldi0+aGRldiwNCj4gPiBISURfRkVB
VFVSRV9SRVBPUlQpOw0KPiA+IMKgCWlmICghcmVwb3J0IHx8IChmaWVsZF9pbmRleCA+PSByZXBv
cnQtPm1heGZpZWxkKSB8fA0KPiA+IA==

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

end of thread, other threads:[~2016-11-13 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11  0:58 [PATCH v2] hid: hid-sensor-hub: clear memory to avoid random data Song Hongyan
2016-11-12 14:43 ` Jonathan Cameron
2016-11-13 14:45   ` Pandruvada, Srinivas

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).