2016-06-16 04:19:46

by Prasun Maiti

[permalink] [raw]
Subject: [PATCH] mwifiex: Fixed endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

The two members min_scan_time and max_scan_time of structure
"mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
are assigned directtly from firmware without endian conversion handling.
So, wrong datas will get saved in big-endian systems.

This patch converts the values into cpu's byte order before assigning them
into the local members.

Signed-off-by: Prasun Maiti <[email protected]>
---
drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c
index 0104108..7dff452 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
@@ -474,8 +474,8 @@ void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
scantlv =
(struct mwifiex_ie_types_btcoex_scan_time *)tlv;
adapter->coex_scan = scantlv->coex_scan;
- adapter->coex_min_scan_time = scantlv->min_scan_time;
- adapter->coex_max_scan_time = scantlv->max_scan_time;
+ adapter->coex_min_scan_time = le16_to_cpu(scantlv->min_scan_time);
+ adapter->coex_max_scan_time = le16_to_cpu(scantlv->max_scan_time);
break;

default:
--
1.9.1



2016-06-30 07:35:19

by Amitkumar Karwar

[permalink] [raw]
Subject: RE: [PATCH] mwifiex: Fixed endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

SGkgUHJhc3VuLA0KDQo+IEZyb206IFByYXN1biBNYWl0aSBbbWFpbHRvOnByYXN1bm1haXRpODdA
Z21haWwuY29tXQ0KPiBTZW50OiBGcmlkYXksIEp1bmUgMjQsIDIwMTYgMTI6MjcgUE0NCj4gVG86
IEFtaXRrdW1hciBLYXJ3YXI7IE5pc2hhbnQgU2FybXVrYWRhbTsgS2FsbGUgVmFsbw0KPiBDYzog
TGludXggV2lyZWxlc3M7IExpbnV4IE5leHQ7IEx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GltZSA9DQo+IGxlMTZfdG9fY3B1KHNjYW50bHYtPm1pbl9z
Y2FuX3RpbWUpOw0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgIGFkYXB0ZXItPmNvZXhfbWF4
X3NjYW5fdGltZSA9DQo+ID4gKyBsZTE2X3RvX2NwdShzY2FudGx2LT5tYXhfc2Nhbl90aW1lKTsN
Cj4gPiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsNCj4gPg0KPiA+ICAgICAgICAgICAg
ICAgICBkZWZhdWx0Og0KPiA+IC0tDQo+ID4gMS45LjENCj4gPg0KDQpBbG9uZyB3aXRoIHRoaXMg
Y2hhbmdlLCB5b3UgbmVlZCB0byBkZWZpbmUgdGhlc2UgZWxlbWVudHMgYXMgX19sZTE2IGluIHNj
YW5fdGx2IHN0cnVjdHVyZS4gRW5zdXJlIHRoYXQgc3BhcnNlIGNvbXBpbGF0aW9uIGlzIHBhc3Nl
ZCB3aXRoIHlvdXIgZmluYWwgcGF0Y2guDQoNClJlZ2FyZHMsDQpBbWl0a3VtYXINCg==

2016-06-24 06:56:57

by Prasun Maiti

[permalink] [raw]
Subject: Re: [PATCH] mwifiex: Fixed endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

On Thu, Jun 16, 2016 at 9:49 AM, Prasun Maiti <[email protected]> wrote:
> The two members min_scan_time and max_scan_time of structure
> "mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
> are assigned directtly from firmware without endian conversion handling.
> So, wrong datas will get saved in big-endian systems.
>
> This patch converts the values into cpu's byte order before assigning them
> into the local members.
>
> Signed-off-by: Prasun Maiti <[email protected]>
> ---
> drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c
> index 0104108..7dff452 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
> @@ -474,8 +474,8 @@ void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
> scantlv =
> (struct mwifiex_ie_types_btcoex_scan_time *)tlv;
> adapter->coex_scan = scantlv->coex_scan;
> - adapter->coex_min_scan_time = scantlv->min_scan_time;
> - adapter->coex_max_scan_time = scantlv->max_scan_time;
> + adapter->coex_min_scan_time = le16_to_cpu(scantlv->min_scan_time);
> + adapter->coex_max_scan_time = le16_to_cpu(scantlv->max_scan_time);
> break;
>
> default:
> --
> 1.9.1
>

Hi Amitkumar,

Please let me know your opinion about this patch.

--
Thanks,
Prasun

2016-06-30 08:55:20

by Amitkumar Karwar

[permalink] [raw]
Subject: RE: [PATCH v2] mwifiex: Fix endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

Hi Prasun,

> -----Original Message-----
> From: Prasun Maiti [mailto:[email protected]]
> Sent: Thursday, June 30, 2016 2:01 PM
> To: Amitkumar Karwar
> Cc: Nishant Sarmukadam; Linux Wireless; Linux Next; Linux Kernel; Kalle
> Valo
> Subject: [PATCH v2] mwifiex: Fix endianness for event TLV type
> TLV_BTCOEX_WL_SCANTIME
>
> The two members min_scan_time and max_scan_time of structure
> "mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
> are assigned directtly from firmware without endian conversion handling.
> So, wrong datas will get saved in big-endian systems.
>
> This patch converts the values into cpu's byte order before assigning
> them into the local members.
>
> Signed-off-by: Prasun Maiti <[email protected]>
> ---
> Changes in v2:
> - Fixed the following sparse compilation warnings:
> * sta_event.c:477:55: warning: cast to restricted __le16
> * sta_event.c:478:55: warning: cast to restricted __le16
>
> drivers/net/wireless/marvell/mwifiex/fw.h | 4 ++--
> drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h
> b/drivers/net/wireless/marvell/mwifiex/fw.h
> index 8e4145a..03d3edf 100644
> --- a/drivers/net/wireless/marvell/mwifiex/fw.h
> +++ b/drivers/net/wireless/marvell/mwifiex/fw.h
> @@ -1958,8 +1958,8 @@ struct mwifiex_ie_types_btcoex_scan_time {
> struct mwifiex_ie_types_header header;
> u8 coex_scan;
> u8 reserved;
> - u16 min_scan_time;
> - u16 max_scan_time;
> + __le16 min_scan_time;
> + __le16 max_scan_time;
> } __packed;
>
> struct mwifiex_ie_types_btcoex_aggr_win_size { diff --git
> a/drivers/net/wireless/marvell/mwifiex/sta_event.c
> b/drivers/net/wireless/marvell/mwifiex/sta_event.c
> index 0104108..7dff452 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
> @@ -474,8 +474,8 @@ void mwifiex_bt_coex_wlan_param_update_event(struct
> mwifiex_private *priv,
> scantlv =
> (struct mwifiex_ie_types_btcoex_scan_time *)tlv;
> adapter->coex_scan = scantlv->coex_scan;
> - adapter->coex_min_scan_time = scantlv->min_scan_time;
> - adapter->coex_max_scan_time = scantlv->max_scan_time;
> + adapter->coex_min_scan_time = le16_to_cpu(scantlv-
> >min_scan_time);
> + adapter->coex_max_scan_time = le16_to_cpu(scantlv-
> >max_scan_time);
> break;
>
> default:
> --
> 1.9.1

Updated change looks fine to me.

Acked-by: Amitkumar Karwar <[email protected]>

Regards,
Amitkumar

2016-06-30 08:31:30

by Prasun Maiti

[permalink] [raw]
Subject: [PATCH v2] mwifiex: Fix endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

The two members min_scan_time and max_scan_time of structure
"mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
are assigned directtly from firmware without endian conversion handling.
So, wrong datas will get saved in big-endian systems.

This patch converts the values into cpu's byte order before assigning them
into the local members.

Signed-off-by: Prasun Maiti <[email protected]>
---
Changes in v2:
- Fixed the following sparse compilation warnings:
* sta_event.c:477:55: warning: cast to restricted __le16
* sta_event.c:478:55: warning: cast to restricted __le16

drivers/net/wireless/marvell/mwifiex/fw.h | 4 ++--
drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index 8e4145a..03d3edf 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -1958,8 +1958,8 @@ struct mwifiex_ie_types_btcoex_scan_time {
struct mwifiex_ie_types_header header;
u8 coex_scan;
u8 reserved;
- u16 min_scan_time;
- u16 max_scan_time;
+ __le16 min_scan_time;
+ __le16 max_scan_time;
} __packed;

struct mwifiex_ie_types_btcoex_aggr_win_size {
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c b/drivers/net/wireless/marvell/mwifiex/sta_event.c
index 0104108..7dff452 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
@@ -474,8 +474,8 @@ void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
scantlv =
(struct mwifiex_ie_types_btcoex_scan_time *)tlv;
adapter->coex_scan = scantlv->coex_scan;
- adapter->coex_min_scan_time = scantlv->min_scan_time;
- adapter->coex_max_scan_time = scantlv->max_scan_time;
+ adapter->coex_min_scan_time = le16_to_cpu(scantlv->min_scan_time);
+ adapter->coex_max_scan_time = le16_to_cpu(scantlv->max_scan_time);
break;

default:
--
1.9.1


2016-06-29 15:54:00

by Kalle Valo

[permalink] [raw]
Subject: Re: mwifiex: Fixed endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

Prasun Maiti <[email protected]> wrote:
> The two members min_scan_time and max_scan_time of structure
> "mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
> are assigned directtly from firmware without endian conversion handling.
> So, wrong datas will get saved in big-endian systems.
>
> This patch converts the values into cpu's byte order before assigning them
> into the local members.
>
> Signed-off-by: Prasun Maiti <[email protected]>

I would like to see Reviewed-by from someone else before I apply this.

--
Sent by pwcli
https://patchwork.kernel.org/patch/9179811/


2016-06-30 09:46:36

by Prasun Maiti

[permalink] [raw]
Subject: Re: [PATCH] mwifiex: Fixed endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

On Thu, Jun 30, 2016 at 1:05 PM, Amitkumar Karwar <[email protected]> wrote:
> Hi Prasun,
>
>> From: Prasun Maiti [mailto:[email protected]]
>> Sent: Friday, June 24, 2016 12:27 PM
>> To: Amitkumar Karwar; Nishant Sarmukadam; Kalle Valo
>> Cc: Linux Wireless; Linux Next; Linux Kernel
>> Subject: Re: [PATCH] mwifiex: Fixed endianness for event TLV type
>> TLV_BTCOEX_WL_SCANTIME
>>
>> On Thu, Jun 16, 2016 at 9:49 AM, Prasun Maiti <[email protected]>
>> wrote:
>> > The two members min_scan_time and max_scan_time of structure
>> > "mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
>> > are assigned directtly from firmware without endian conversion
>> handling.
>> > So, wrong datas will get saved in big-endian systems.
>> >
>> > This patch converts the values into cpu's byte order before assigning
>> > them into the local members.
>> >
>> > Signed-off-by: Prasun Maiti <[email protected]>
>> > ---
>> > drivers/net/wireless/marvell/mwifiex/sta_event.c | 4 ++--
>> > 1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c
>> > b/drivers/net/wireless/marvell/mwifiex/sta_event.c
>> > index 0104108..7dff452 100644
>> > --- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
>> > +++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
>> > @@ -474,8 +474,8 @@ void
>> mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
>> > scantlv =
>> > (struct mwifiex_ie_types_btcoex_scan_time
>> *)tlv;
>> > adapter->coex_scan = scantlv->coex_scan;
>> > - adapter->coex_min_scan_time = scantlv-
>> >min_scan_time;
>> > - adapter->coex_max_scan_time = scantlv-
>> >max_scan_time;
>> > + adapter->coex_min_scan_time =
>> le16_to_cpu(scantlv->min_scan_time);
>> > + adapter->coex_max_scan_time =
>> > + le16_to_cpu(scantlv->max_scan_time);
>> > break;
>> >
>> > default:
>> > --
>> > 1.9.1
>> >
>
> Along with this change, you need to define these elements as __le16 in scan_tlv structure. Ensure that sparse compilation is passed with your final patch.
>

Hi Amitkumar,

Thanks for your suggestion.
I have added this in scan_tlv structure to fix the sparse compilation
warnings. Updated patch v2 is sent.
Please verify this.

--
Thanks,
Prasun

2016-06-30 08:41:17

by Prasun Maiti

[permalink] [raw]
Subject: Re: [PATCH v2] mwifiex: Fix endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

On Thu, Jun 30, 2016 at 2:07 PM, Amitkumar Karwar <[email protected]> wrote:
> Hi Prasun,
> Updated change looks fine to me.
>
> Acked-by: Amitkumar Karwar <[email protected]>
>
> Regards,
> Amitkumar

Hi AmitKumar,

Thanks for your verification.

--
Thanks,
Prasun

2016-07-08 13:47:05

by Kalle Valo

[permalink] [raw]
Subject: Re: [v2] mwifiex: Fix endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

Prasun Maiti <[email protected]> wrote:
> The two members min_scan_time and max_scan_time of structure
> "mwifiex_ie_types_btcoex_scan_time" are of two bytes each. The values
> are assigned directtly from firmware without endian conversion handling.
> So, wrong datas will get saved in big-endian systems.
>
> This patch converts the values into cpu's byte order before assigning them
> into the local members.
>
> Signed-off-by: Prasun Maiti <[email protected]>
> Acked-by: Amitkumar Karwar <[email protected]>

Thanks, 1 patch applied to wireless-drivers-next.git:

c18b104dd249 mwifiex: Fix endianness for event TLV type TLV_BTCOEX_WL_SCANTIME

--
Sent by pwcli
https://patchwork.kernel.org/patch/9206939/