* [PATCH] iw: Null check before accessing n_mcs variable [not found] <CGME20170901061008epcms5p5fdd787910f9698c511e01a134afe90ea@epcms5p5> @ 2017-09-01 6:10 ` Amit Khatri 2017-09-06 10:39 ` Johannes Berg 0 siblings, 1 reply; 2+ messages in thread From: Amit Khatri @ 2017-09-01 6:10 UTC (permalink / raw) To: johannes@sipsolutions.net; +Cc: linux-wireless@vger.kernel.org, Nitin Jhanwar From: Amit Khatri <amit.khatri@samsung.com> Date: Thu, 24 Aug 2017 00:16:26 -0700 Subject: [PATCH] iw: Null check before accessing n_mcs variable If all cases will fail n_mcs variable fail to get any assignement and remain NULL. so better to check NULL before dereference. Signed-off-by: Amit Khatri <amit.khatri@samsung.com> --- bitrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitrate.c b/bitrate.c index 4a026a4..3e58337 100644 --- a/bitrate.c +++ b/bitrate.c @@ -185,7 +185,8 @@ static int handle_bitrates(struct nl80211_state *state, return 1; if (tmpl < 0 || tmpl > 255) return 1; - mcs[(*n_mcs)++] = tmpl; + if(n_mcs!=NULL) + mcs[(*n_mcs)++] = tmpl; break; case S_VHT: if (*vht_argc >= VHT_ARGC_MAX) -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iw: Null check before accessing n_mcs variable 2017-09-01 6:10 ` [PATCH] iw: Null check before accessing n_mcs variable Amit Khatri @ 2017-09-06 10:39 ` Johannes Berg 0 siblings, 0 replies; 2+ messages in thread From: Johannes Berg @ 2017-09-06 10:39 UTC (permalink / raw) To: amit.khatri; +Cc: linux-wireless@vger.kernel.org, Nitin Jhanwar On Fri, 2017-09-01 at 06:10 +0000, Amit Khatri wrote: > From: Amit Khatri <amit.khatri@samsung.com> > Date: Thu, 24 Aug 2017 00:16:26 -0700 > Subject: [PATCH] iw: Null check before accessing n_mcs variable > > If all cases will fail n_mcs variable fail to get any assignement > and remain NULL. so better to check NULL before dereference. > This is wrong - you can't get into S_HT state unless n_mcs was also assigned, and if you can't get into S_HT state then you can't dereference n_mcs either. johannes ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-06 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20170901061008epcms5p5fdd787910f9698c511e01a134afe90ea@epcms5p5>
2017-09-01 6:10 ` [PATCH] iw: Null check before accessing n_mcs variable Amit Khatri
2017-09-06 10:39 ` Johannes Berg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox