2015-07-16 03:56:09

by Maninder Singh

[permalink] [raw]
Subject: [PATCH 1/1] ath10k: fixing wrong initialization of struct channel

chandef is initialized with NULL and on the very next line,
we are using it to get channel, which is not correct.

channel should be initialized after obtaining chandef.

Signed-off-by: Maninder Singh <[email protected]>
---
drivers/net/wireless/ath/ath10k/mac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 218b6af..3d196b5 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -836,7 +836,7 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
{
struct cfg80211_chan_def *chandef = NULL;
- struct ieee80211_channel *channel = chandef->chan;
+ struct ieee80211_channel *channel = NULL;
struct wmi_vdev_start_request_arg arg = {};
int ret = 0;

--
1.7.9.5



2015-07-21 11:59:47

by Maninder Singh

[permalink] [raw]
Subject: Re: [PATCH 1/1] ath10k: fixing wrong initialization of struct channel

Pj4gY2hhbmRlZiBpcyBpbml0aWFsaXplZCB3aXRoIE5VTEwgYW5kIG9uIHRoZSB2ZXJ5IG5leHQg
bGluZSwNCj4+IHdlIGFyZSB1c2luZyBpdCB0byBnZXQgY2hhbm5lbCwgd2hpY2ggaXMgbm90IGNv
cnJlY3QuDQo+Pg0KPj4gY2hhbm5lbCBzaG91bGQgYmUgaW5pdGlhbGl6ZWQgYWZ0ZXIgb2J0YWlu
aW5nIGNoYW5kZWYuDQo+Pg0KPj4gU2lnbmVkLW9mZi1ieTogTWFuaW5kZXIgU2luZ2ggPG1hbmlu
ZGVyMS5zQHNhbXN1bmcuY29tPg0KDQo+SG93IGRpZCB5b3UgZmluZCB0aGlzIGJ1Zz8NCg0KU3Rh
dGljIGFubHlzaXMgcmVwb3J0cyB0aGlzIGJ1ZyBsaWtlIGNvdmVyaXR5IG9yIGFueSBvdGhlciBz
dGF0aWMgdG9vbCBsaWtlIGNwcGNoZWNrIDotDQoNCmRyaXZlcnMvbmV0L3dpcmVsZXNzL2F0aC9h
dGgxMGsvbWFjLmM6ODM5XTogKGVycm9yKSBQb3NzaWJsZSBudWxsIHBvaW50ZXIgZGVyZWZlcmVu
Y2U6IGNoYW5kZWYNCg0KVGhhbmtzLA0KTWFuaW5kZXI=



2015-07-21 11:54:41

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/1] ath10k: fixing wrong initialization of struct channel

Maninder Singh <[email protected]> writes:

> chandef is initialized with NULL and on the very next line,
> we are using it to get channel, which is not correct.
>
> channel should be initialized after obtaining chandef.
>
> Signed-off-by: Maninder Singh <[email protected]>

How did you find this bug?

--
Kalle Valo

2015-07-21 15:56:13

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/1] ath10k: fixing wrong initialization of struct channel

Maninder Singh <[email protected]> writes:

>>> chandef is initialized with NULL and on the very next line,
>>> we are using it to get channel, which is not correct.
>>>
>>> channel should be initialized after obtaining chandef.
>>>
>>> Signed-off-by: Maninder Singh <[email protected]>
>
>>How did you find this bug?
>
> Static anlysis reports this bug like coverity or any other static tool like cppcheck :-
>
> drivers/net/wireless/ath/ath10k/mac.c:839]: (error) Possible null pointer dereference: chandef

Thanks. This is always good to add to the commit log so I did that:

ath10k: fix wrong initialization of struct channel

chandef is initialized with NULL and on the very next line, we are using it to
get channel, which is not correct. Channel should be initialized after
obtaining chandef.

Found by cppcheck:

ath/ath10k/mac.c:839]: (error) Possible null pointer dereference: chandef

Signed-off-by: Maninder Singh <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>


--
Kalle Valo

2015-07-24 07:48:21

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH 1/1] ath10k: fixing wrong initialization of struct channel

Maninder Singh <[email protected]> writes:

> chandef is initialized with NULL and on the very next line,
> we are using it to get channel, which is not correct.
>
> channel should be initialized after obtaining chandef.
>
> Signed-off-by: Maninder Singh <[email protected]>

Thanks, applied.

--
Kalle Valo