[PATCH 4.19 37/40] wil6210: add general initialization/size checks

From: Greg Kroah-Hartman
Date: Mon Apr 20 2020 - 08:49:32 EST


From: Alexei Avshalom Lazar <ailizaro@xxxxxxxxxxxxxx>

commit ac0e541ab2f2951845acee784ef487be40fb4c77 upstream.

Initialize unset variable, and verify that mid is valid.

Signed-off-by: Alexei Avshalom Lazar <ailizaro@xxxxxxxxxxxxxx>
Signed-off-by: Maya Erez <merez@xxxxxxxxxxxxxx>
Signed-off-by: Kalle Valo <kvalo@xxxxxxxxxxxxxx>
Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/net/wireless/ath/wil6210/debugfs.c | 2 ++
drivers/net/wireless/ath/wil6210/wmi.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -991,6 +991,8 @@ static ssize_t wil_write_file_txmgmt(str
int rc;
void *frame;

+ memset(&params, 0, sizeof(params));
+
if (!len)
return -EINVAL;

--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -2802,7 +2802,7 @@ static void wmi_event_handle(struct wil6

if (mid == MID_BROADCAST)
mid = 0;
- if (mid >= wil->max_vifs) {
+ if (mid >= ARRAY_SIZE(wil->vifs) || mid >= wil->max_vifs) {
wil_dbg_wmi(wil, "invalid mid %d, event skipped\n",
mid);
return;