linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors
@ 2018-11-06  0:01 Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 1/4] staging: wilc1000: remove unused flags in handle_cfg_param() Adham.Abozaeid
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Adham.Abozaeid @ 2018-11-06  0:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: devel, gregkh, Ganesh.Krishna, Aditya.Shankar, johannes

From: Adham Abozaeid <adham.abozaeid@micochip.com>

Validate input parameters to set_wiphy_param before scheduling
handle_cfg_param() to validate them.
This way proper errors can be returned to caller.
Also cleaned up unused code in handle_cfg_param.

Changes since v1:
- Correction spelling in subject of patch#2
- Added From: tag to have correct email from value

Changes since v2:
- Reverted unnecessary file permission changes

Adham Abozaeid (4):
  staging: wilc1000: remove unused flags in handle_cfg_param()
  staging: wilc1000: validate cfg parameters before scheduling the work
  staging: wilc1000: Don't keep a copy of wiphy parameters in the driver
  staging: wilc1000: Remove unused mutex cfg_values_lock

 drivers/staging/wilc1000/host_interface.c     | 291 +-----------------
 drivers/staging/wilc1000/host_interface.h     |  32 --
 .../staging/wilc1000/wilc_wfi_cfgoperations.c |  50 ++-
 drivers/staging/wilc1000/wilc_wlan_if.h       |   9 -
 4 files changed, 58 insertions(+), 324 deletions(-)

-- 
2.17.1


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

* [PATCH v3 1/4] staging: wilc1000: remove unused flags in handle_cfg_param()
  2018-11-06  0:01 [PATCH v3 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors Adham.Abozaeid
@ 2018-11-06  0:01 ` Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work Adham.Abozaeid
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Adham.Abozaeid @ 2018-11-06  0:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: devel, gregkh, Ganesh.Krishna, Aditya.Shankar, johannes

From: Adham Abozaeid <adham.abozaeid@micochip.com>

handle_cfg_param() receives a bit map that describes what to be changed.
Some of these bits flags aren't referred to from elsewhere and can be
removed.

Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
---
 drivers/staging/wilc1000/host_interface.c | 216 ----------------------
 drivers/staging/wilc1000/host_interface.h |  29 ---
 drivers/staging/wilc1000/wilc_wlan_if.h   |   9 -
 3 files changed, 254 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index c4f858b22914..b89116c57064 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -374,64 +374,6 @@ static void handle_cfg_param(struct work_struct *work)
 
 	mutex_lock(&hif_drv->cfg_values_lock);
 
-	if (param->flag & BSS_TYPE) {
-		u8 bss_type = param->bss_type;
-
-		if (bss_type < 6) {
-			wid_list[i].id = WID_BSS_TYPE;
-			wid_list[i].val = (s8 *)&param->bss_type;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.bss_type = bss_type;
-		} else {
-			netdev_err(vif->ndev, "check value 6 over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & AUTH_TYPE) {
-		u8 auth_type = param->auth_type;
-
-		if (auth_type == 1 || auth_type == 2 || auth_type == 5) {
-			wid_list[i].id = WID_AUTH_TYPE;
-			wid_list[i].val = (s8 *)&param->auth_type;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.auth_type = auth_type;
-		} else {
-			netdev_err(vif->ndev, "Impossible value\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & AUTHEN_TIMEOUT) {
-		if (param->auth_timeout > 0) {
-			wid_list[i].id = WID_AUTH_TIMEOUT;
-			wid_list[i].val = (s8 *)&param->auth_timeout;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.auth_timeout = param->auth_timeout;
-		} else {
-			netdev_err(vif->ndev, "Range(1 ~ 65535) over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & POWER_MANAGEMENT) {
-		u8 pm_mode = param->power_mgmt_mode;
-
-		if (pm_mode < 5) {
-			wid_list[i].id = WID_POWER_MANAGEMENT;
-			wid_list[i].val = (s8 *)&param->power_mgmt_mode;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.power_mgmt_mode = pm_mode;
-		} else {
-			netdev_err(vif->ndev, "Invalid power mode\n");
-			goto unlock;
-		}
-		i++;
-	}
 	if (param->flag & RETRY_SHORT) {
 		u16 retry_limit = param->short_retry_limit;
 
@@ -492,160 +434,6 @@ static void handle_cfg_param(struct work_struct *work)
 		}
 		i++;
 	}
-	if (param->flag & PREAMBLE) {
-		u16 preamble_type = param->preamble_type;
-
-		if (param->preamble_type < 3) {
-			wid_list[i].id = WID_PREAMBLE;
-			wid_list[i].val = (s8 *)&param->preamble_type;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.preamble_type = preamble_type;
-		} else {
-			netdev_err(vif->ndev, "Preamble Range(0~2) over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & SHORT_SLOT_ALLOWED) {
-		u8 slot_allowed = param->short_slot_allowed;
-
-		if (slot_allowed < 2) {
-			wid_list[i].id = WID_SHORT_SLOT_ALLOWED;
-			wid_list[i].val = (s8 *)&param->short_slot_allowed;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.short_slot_allowed = slot_allowed;
-		} else {
-			netdev_err(vif->ndev, "Short slot(2) over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & TXOP_PROT_DISABLE) {
-		u8 prot_disabled = param->txop_prot_disabled;
-
-		if (param->txop_prot_disabled < 2) {
-			wid_list[i].id = WID_11N_TXOP_PROT_DISABLE;
-			wid_list[i].val = (s8 *)&param->txop_prot_disabled;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.txop_prot_disabled = prot_disabled;
-		} else {
-			netdev_err(vif->ndev, "TXOP prot disable\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & BEACON_INTERVAL) {
-		u16 beacon_interval = param->beacon_interval;
-
-		if (beacon_interval > 0) {
-			wid_list[i].id = WID_BEACON_INTERVAL;
-			wid_list[i].val = (s8 *)&param->beacon_interval;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.beacon_interval = beacon_interval;
-		} else {
-			netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & DTIM_PERIOD) {
-		if (param->dtim_period > 0 && param->dtim_period < 256) {
-			wid_list[i].id = WID_DTIM_PERIOD;
-			wid_list[i].val = (s8 *)&param->dtim_period;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.dtim_period = param->dtim_period;
-		} else {
-			netdev_err(vif->ndev, "DTIM range(1~255) fail\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & SITE_SURVEY) {
-		enum site_survey enabled = param->site_survey_enabled;
-
-		if (enabled < 3) {
-			wid_list[i].id = WID_SITE_SURVEY;
-			wid_list[i].val = (s8 *)&param->site_survey_enabled;
-			wid_list[i].type = WID_CHAR;
-			wid_list[i].size = sizeof(char);
-			hif_drv->cfg_values.site_survey_enabled = enabled;
-		} else {
-			netdev_err(vif->ndev, "Site survey disable\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & SITE_SURVEY_SCAN_TIME) {
-		u16 scan_time = param->site_survey_scan_time;
-
-		if (scan_time > 0) {
-			wid_list[i].id = WID_SITE_SURVEY_SCAN_TIME;
-			wid_list[i].val = (s8 *)&param->site_survey_scan_time;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.site_survey_scan_time = scan_time;
-		} else {
-			netdev_err(vif->ndev, "Site scan time(1~65535) over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & ACTIVE_SCANTIME) {
-		u16 active_scan_time = param->active_scan_time;
-
-		if (active_scan_time > 0) {
-			wid_list[i].id = WID_ACTIVE_SCAN_TIME;
-			wid_list[i].val = (s8 *)&param->active_scan_time;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.active_scan_time = active_scan_time;
-		} else {
-			netdev_err(vif->ndev, "Active time(1~65535) over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & PASSIVE_SCANTIME) {
-		u16 time = param->passive_scan_time;
-
-		if (time > 0) {
-			wid_list[i].id = WID_PASSIVE_SCAN_TIME;
-			wid_list[i].val = (s8 *)&param->passive_scan_time;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.passive_scan_time = time;
-		} else {
-			netdev_err(vif->ndev, "Passive time(1~65535) over\n");
-			goto unlock;
-		}
-		i++;
-	}
-	if (param->flag & CURRENT_TX_RATE) {
-		enum current_tx_rate curr_tx_rate = param->curr_tx_rate;
-
-		if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 ||
-		    curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 ||
-		    curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 ||
-		    curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 ||
-		    curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 ||
-		    curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 ||
-		    curr_tx_rate == MBPS_54) {
-			wid_list[i].id = WID_CURRENT_TX_RATE;
-			wid_list[i].val = (s8 *)&curr_tx_rate;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
-		} else {
-			netdev_err(vif->ndev, "out of TX rate\n");
-			goto unlock;
-		}
-		i++;
-	}
 
 	ret = wilc_send_config_pkt(vif, SET_CFG, wid_list,
 				   i, wilc_get_vif_idx(vif));
@@ -3489,11 +3277,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 	mutex_lock(&hif_drv->cfg_values_lock);
 
 	hif_drv->hif_state = HOST_IF_IDLE;
-	hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
 	hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
-	hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
-	hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
-	hif_drv->cfg_values.curr_tx_rate = AUTORATE;
 
 	hif_drv->p2p_timeout = 0;
 
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 5f8d30f47cd6..df9fc33be094 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -158,26 +158,11 @@ enum current_tx_rate {
 struct cfg_param_attr {
 	u32 flag;
 	u8 ht_enable;
-	u8 bss_type;
-	u8 auth_type;
-	u16 auth_timeout;
-	u8 power_mgmt_mode;
 	u16 short_retry_limit;
 	u16 long_retry_limit;
 	u16 frag_threshold;
 	u16 rts_threshold;
-	u16 preamble_type;
-	u8 short_slot_allowed;
-	u8 txop_prot_disabled;
-	u16 beacon_interval;
-	u16 dtim_period;
-	enum site_survey site_survey_enabled;
-	u16 site_survey_scan_time;
 	u8 scan_source;
-	u16 active_scan_time;
-	u16 passive_scan_time;
-	enum current_tx_rate curr_tx_rate;
-
 };
 
 enum cfg_param {
@@ -185,20 +170,6 @@ enum cfg_param {
 	RETRY_LONG		= BIT(1),
 	FRAG_THRESHOLD		= BIT(2),
 	RTS_THRESHOLD		= BIT(3),
-	BSS_TYPE		= BIT(4),
-	AUTH_TYPE		= BIT(5),
-	AUTHEN_TIMEOUT		= BIT(6),
-	POWER_MANAGEMENT	= BIT(7),
-	PREAMBLE		= BIT(8),
-	SHORT_SLOT_ALLOWED	= BIT(9),
-	TXOP_PROT_DISABLE	= BIT(10),
-	BEACON_INTERVAL		= BIT(11),
-	DTIM_PERIOD		= BIT(12),
-	SITE_SURVEY		= BIT(13),
-	SITE_SURVEY_SCAN_TIME	= BIT(14),
-	ACTIVE_SCANTIME		= BIT(15),
-	PASSIVE_SCANTIME	= BIT(16),
-	CURRENT_TX_RATE		= BIT(17),
 	HT_ENABLE		= BIT(18),
 };
 
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h
index ce2066b74287..4f258bf6a48d 100644
--- a/drivers/staging/wilc1000/wilc_wlan_if.h
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -698,13 +698,8 @@ enum {
 	WID_LONG_RETRY_LIMIT		= 0x1003,
 	WID_BEACON_INTERVAL		= 0x1006,
 	WID_MEMORY_ACCESS_16BIT		= 0x1008,
-	WID_RX_SENSE			= 0x100B,
-	WID_ACTIVE_SCAN_TIME		= 0x100C,
-	WID_PASSIVE_SCAN_TIME		= 0x100D,
 
-	WID_SITE_SURVEY_SCAN_TIME	= 0x100E,
 	WID_JOIN_START_TIMEOUT		= 0x100F,
-	WID_AUTH_TIMEOUT		= 0x1010,
 	WID_ASOC_TIMEOUT		= 0x1011,
 	WID_11I_PROTOCOL_TIMEOUT	= 0x1012,
 	WID_EAPOL_RESPONSE_TIMEOUT	= 0x1013,
@@ -739,11 +734,8 @@ enum {
 	WID_HW_RX_COUNT			= 0x2015,
 	WID_MEMORY_ADDRESS		= 0x201E,
 	WID_MEMORY_ACCESS_32BIT		= 0x201F,
-	WID_RF_REG_VAL			= 0x2021,
 
 	/* NMAC Integer WID list */
-	WID_11N_PHY_ACTIVE_REG_VAL	= 0x2080,
-
 	/* Custom Integer WID list */
 	WID_GET_INACTIVE_TIME		= 0x2084,
 	WID_SET_OPERATION_MODE		= 0X2086,
@@ -764,7 +756,6 @@ enum {
 	WID_SUPP_PASSWORD		= 0x3011,
 	WID_SITE_SURVEY_RESULTS		= 0x3012,
 	WID_RX_POWER_LEVEL		= 0x3013,
-	WID_DEL_ALL_RX_BA		= 0x3014,
 	WID_SET_STA_MAC_INACTIVE_TIME	= 0x3017,
 	WID_ADD_WEP_KEY			= 0x3019,
 	WID_REMOVE_WEP_KEY		= 0x301A,
-- 
2.17.1


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

* [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work
  2018-11-06  0:01 [PATCH v3 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 1/4] staging: wilc1000: remove unused flags in handle_cfg_param() Adham.Abozaeid
@ 2018-11-06  0:01 ` Adham.Abozaeid
  2018-11-07  8:46   ` kbuild test robot
  2018-11-08 11:22   ` Greg KH
  2018-11-06  0:01 ` [PATCH v3 4/4] staging: wilc1000: Remove unused mutex cfg_values_lock Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 3/4] staging: wilc1000: Don't keep a copy of wiphy parameters in the driver Adham.Abozaeid
  3 siblings, 2 replies; 8+ messages in thread
From: Adham.Abozaeid @ 2018-11-06  0:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: devel, gregkh, Ganesh.Krishna, Aditya.Shankar, johannes

From: Adham Abozaeid <adham.abozaeid@micochip.com>

Validate cfg parameters after being called by cfg80211 in set_wiphy_params
before scheduling the work executed in handle_cfg_param

Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
---
 drivers/staging/wilc1000/host_interface.c     | 61 ++++++-------------
 .../staging/wilc1000/wilc_wfi_cfgoperations.c | 50 ++++++++++++---
 2 files changed, 62 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index b89116c57064..c1215c194907 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -377,61 +377,41 @@ static void handle_cfg_param(struct work_struct *work)
 	if (param->flag & RETRY_SHORT) {
 		u16 retry_limit = param->short_retry_limit;
 
-		if (retry_limit > 0 && retry_limit < 256) {
-			wid_list[i].id = WID_SHORT_RETRY_LIMIT;
-			wid_list[i].val = (s8 *)&param->short_retry_limit;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.short_retry_limit = retry_limit;
-		} else {
-			netdev_err(vif->ndev, "Range(1~256) over\n");
-			goto unlock;
-		}
+		wid_list[i].id = WID_SHORT_RETRY_LIMIT;
+		wid_list[i].val = (s8 *)&param->short_retry_limit;
+		wid_list[i].type = WID_SHORT;
+		wid_list[i].size = sizeof(u16);
+		hif_drv->cfg_values.short_retry_limit = retry_limit;
 		i++;
 	}
 	if (param->flag & RETRY_LONG) {
 		u16 limit = param->long_retry_limit;
 
-		if (limit > 0 && limit < 256) {
-			wid_list[i].id = WID_LONG_RETRY_LIMIT;
-			wid_list[i].val = (s8 *)&param->long_retry_limit;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.long_retry_limit = limit;
-		} else {
-			netdev_err(vif->ndev, "Range(1~256) over\n");
-			goto unlock;
-		}
+		wid_list[i].id = WID_LONG_RETRY_LIMIT;
+		wid_list[i].val = (s8 *)&param->long_retry_limit;
+		wid_list[i].type = WID_SHORT;
+		wid_list[i].size = sizeof(u16);
+		hif_drv->cfg_values.long_retry_limit = limit;
 		i++;
 	}
 	if (param->flag & FRAG_THRESHOLD) {
 		u16 frag_th = param->frag_threshold;
 
-		if (frag_th > 255 && frag_th < 7937) {
-			wid_list[i].id = WID_FRAG_THRESHOLD;
-			wid_list[i].val = (s8 *)&param->frag_threshold;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.frag_threshold = frag_th;
-		} else {
-			netdev_err(vif->ndev, "Threshold Range fail\n");
-			goto unlock;
-		}
+		wid_list[i].id = WID_FRAG_THRESHOLD;
+		wid_list[i].val = (s8 *)&param->frag_threshold;
+		wid_list[i].type = WID_SHORT;
+		wid_list[i].size = sizeof(u16);
+		hif_drv->cfg_values.frag_threshold = frag_th;
 		i++;
 	}
 	if (param->flag & RTS_THRESHOLD) {
 		u16 rts_th = param->rts_threshold;
 
-		if (rts_th > 255) {
-			wid_list[i].id = WID_RTS_THRESHOLD;
-			wid_list[i].val = (s8 *)&param->rts_threshold;
-			wid_list[i].type = WID_SHORT;
-			wid_list[i].size = sizeof(u16);
-			hif_drv->cfg_values.rts_threshold = rts_th;
-		} else {
-			netdev_err(vif->ndev, "Threshold Range fail\n");
-			goto unlock;
-		}
+		wid_list[i].id = WID_RTS_THRESHOLD;
+		wid_list[i].val = (s8 *)&param->rts_threshold;
+		wid_list[i].type = WID_SHORT;
+		wid_list[i].size = sizeof(u16);
+		hif_drv->cfg_values.rts_threshold = rts_th;
 		i++;
 	}
 
@@ -441,7 +421,6 @@ static void handle_cfg_param(struct work_struct *work)
 	if (ret)
 		netdev_err(vif->ndev, "Error in setting CFG params\n");
 
-unlock:
 	mutex_unlock(&hif_drv->cfg_values_lock);
 	kfree(msg);
 }
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 4fbbbbd5a64b..26bb78a49d81 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1149,21 +1149,55 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
 	cfg_param_val.flag = 0;
 
 	if (changed & WIPHY_PARAM_RETRY_SHORT) {
-		cfg_param_val.flag  |= RETRY_SHORT;
-		cfg_param_val.short_retry_limit = wiphy->retry_short;
+		if (wiphy->retry_short > 0 && wiphy->retry_short < 256) {
+			netdev_dbg(vif->ndev,
+				   "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
+				   wiphy->retry_short);
+			cfg_param_val.flag  |= RETRY_SHORT;
+			cfg_param_val.short_retry_limit = wiphy->retry_short;
+		} else {
+			netdev_err(vif->ndev, "Short retry limit out of range\n");
+			return -EINVAL;
+		}
 	}
 	if (changed & WIPHY_PARAM_RETRY_LONG) {
-		cfg_param_val.flag |= RETRY_LONG;
-		cfg_param_val.long_retry_limit = wiphy->retry_long;
+		if (wiphy->retry_long > 0 && wiphy->retry_long < 256) {
+			netdev_dbg(vif->ndev,
+				   "Setting WIPHY_PARAM_RETRY_LONG %d\n",
+				   wiphy->retry_long);
+			cfg_param_val.flag |= RETRY_LONG;
+			cfg_param_val.long_retry_limit = wiphy->retry_long;
+		} else {
+			netdev_err(vif->ndev, "Long retry limit out of range\n");
+			return -EINVAL;
+		}
 	}
 	if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
-		cfg_param_val.flag |= FRAG_THRESHOLD;
-		cfg_param_val.frag_threshold = wiphy->frag_threshold;
+		if (wiphy->frag_threshold > 255 &&
+		    wiphy->frag_threshold < 7937) {
+			netdev_dbg(vif->ndev,
+				   "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n",
+				   wiphy->frag_threshold);
+			cfg_param_val.flag |= FRAG_THRESHOLD;
+			cfg_param_val.frag_threshold = wiphy->frag_threshold;
+		} else {
+			netdev_err(vif->ndev,
+				   "Fragmentation threshold out of range\n");
+			return -EINVAL;
+		}
 	}
 
 	if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
-		cfg_param_val.flag |= RTS_THRESHOLD;
-		cfg_param_val.rts_threshold = wiphy->rts_threshold;
+		if (wiphy->rts_threshold > 255) {
+			netdev_dbg(vif->ndev,
+				   "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n",
+				   wiphy->rts_threshold);
+			cfg_param_val.flag |= RTS_THRESHOLD;
+			cfg_param_val.rts_threshold = wiphy->rts_threshold;
+		} else {
+			netdev_err(vif->ndev, "RTS threshold out of range\n");
+			return -EINVAL;
+		}
 	}
 
 	ret = wilc_hif_set_cfg(vif, &cfg_param_val);
-- 
2.17.1


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

* [PATCH v3 4/4] staging: wilc1000: Remove unused mutex cfg_values_lock
  2018-11-06  0:01 [PATCH v3 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 1/4] staging: wilc1000: remove unused flags in handle_cfg_param() Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work Adham.Abozaeid
@ 2018-11-06  0:01 ` Adham.Abozaeid
  2018-11-06  0:01 ` [PATCH v3 3/4] staging: wilc1000: Don't keep a copy of wiphy parameters in the driver Adham.Abozaeid
  3 siblings, 0 replies; 8+ messages in thread
From: Adham.Abozaeid @ 2018-11-06  0:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: devel, gregkh, Ganesh.Krishna, Aditya.Shankar, johannes

From: Adham Abozaeid <adham.abozaeid@micochip.com>

After removing cfg_values member, cfg_values_lock that was used to protect
it can also be removed.

Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
---
 drivers/staging/wilc1000/host_interface.c | 9 ---------
 drivers/staging/wilc1000/host_interface.h | 2 --
 2 files changed, 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 8d1142776310..2bf91df1ded1 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -369,11 +369,8 @@ static void handle_cfg_param(struct work_struct *work)
 	struct cfg_param_attr *param = &msg->body.cfg_info;
 	int ret;
 	struct wid wid_list[32];
-	struct host_if_drv *hif_drv = vif->hif_drv;
 	int i = 0;
 
-	mutex_lock(&hif_drv->cfg_values_lock);
-
 	if (param->flag & RETRY_SHORT) {
 		wid_list[i].id = WID_SHORT_RETRY_LIMIT;
 		wid_list[i].val = (s8 *)&param->short_retry_limit;
@@ -409,7 +406,6 @@ static void handle_cfg_param(struct work_struct *work)
 	if (ret)
 		netdev_err(vif->ndev, "Error in setting CFG params\n");
 
-	mutex_unlock(&hif_drv->cfg_values_lock);
 	kfree(msg);
 }
 
@@ -3240,15 +3236,10 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 	timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0);
 	timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0);
 
-	mutex_init(&hif_drv->cfg_values_lock);
-	mutex_lock(&hif_drv->cfg_values_lock);
-
 	hif_drv->hif_state = HOST_IF_IDLE;
 
 	hif_drv->p2p_timeout = 0;
 
-	mutex_unlock(&hif_drv->cfg_values_lock);
-
 	wilc->clients_count++;
 
 	return 0;
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index 1e2e50e91f76..523b46bfb488 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -293,8 +293,6 @@ struct host_if_drv {
 	enum host_if_state hif_state;
 
 	u8 assoc_bssid[ETH_ALEN];
-	/*lock to protect concurrent setting of cfg params*/
-	struct mutex cfg_values_lock;
 
 	struct timer_list scan_timer;
 	struct wilc_vif *scan_timer_vif;
-- 
2.17.1


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

* [PATCH v3 3/4] staging: wilc1000: Don't keep a copy of wiphy parameters in the driver
  2018-11-06  0:01 [PATCH v3 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors Adham.Abozaeid
                   ` (2 preceding siblings ...)
  2018-11-06  0:01 ` [PATCH v3 4/4] staging: wilc1000: Remove unused mutex cfg_values_lock Adham.Abozaeid
@ 2018-11-06  0:01 ` Adham.Abozaeid
  3 siblings, 0 replies; 8+ messages in thread
From: Adham.Abozaeid @ 2018-11-06  0:01 UTC (permalink / raw)
  To: linux-wireless; +Cc: devel, gregkh, Ganesh.Krishna, Aditya.Shankar, johannes

From: Adham Abozaeid <adham.abozaeid@micochip.com>

host_if_drv.cfg_values is a write only member, and can be removed

Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
---
 drivers/staging/wilc1000/host_interface.c | 13 -------------
 drivers/staging/wilc1000/host_interface.h |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index c1215c194907..8d1142776310 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -375,43 +375,31 @@ static void handle_cfg_param(struct work_struct *work)
 	mutex_lock(&hif_drv->cfg_values_lock);
 
 	if (param->flag & RETRY_SHORT) {
-		u16 retry_limit = param->short_retry_limit;
-
 		wid_list[i].id = WID_SHORT_RETRY_LIMIT;
 		wid_list[i].val = (s8 *)&param->short_retry_limit;
 		wid_list[i].type = WID_SHORT;
 		wid_list[i].size = sizeof(u16);
-		hif_drv->cfg_values.short_retry_limit = retry_limit;
 		i++;
 	}
 	if (param->flag & RETRY_LONG) {
-		u16 limit = param->long_retry_limit;
-
 		wid_list[i].id = WID_LONG_RETRY_LIMIT;
 		wid_list[i].val = (s8 *)&param->long_retry_limit;
 		wid_list[i].type = WID_SHORT;
 		wid_list[i].size = sizeof(u16);
-		hif_drv->cfg_values.long_retry_limit = limit;
 		i++;
 	}
 	if (param->flag & FRAG_THRESHOLD) {
-		u16 frag_th = param->frag_threshold;
-
 		wid_list[i].id = WID_FRAG_THRESHOLD;
 		wid_list[i].val = (s8 *)&param->frag_threshold;
 		wid_list[i].type = WID_SHORT;
 		wid_list[i].size = sizeof(u16);
-		hif_drv->cfg_values.frag_threshold = frag_th;
 		i++;
 	}
 	if (param->flag & RTS_THRESHOLD) {
-		u16 rts_th = param->rts_threshold;
-
 		wid_list[i].id = WID_RTS_THRESHOLD;
 		wid_list[i].val = (s8 *)&param->rts_threshold;
 		wid_list[i].type = WID_SHORT;
 		wid_list[i].size = sizeof(u16);
-		hif_drv->cfg_values.rts_threshold = rts_th;
 		i++;
 	}
 
@@ -3256,7 +3244,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 	mutex_lock(&hif_drv->cfg_values_lock);
 
 	hif_drv->hif_state = HOST_IF_IDLE;
-	hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
 
 	hif_drv->p2p_timeout = 0;
 
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
index df9fc33be094..1e2e50e91f76 100644
--- a/drivers/staging/wilc1000/host_interface.h
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -293,7 +293,6 @@ struct host_if_drv {
 	enum host_if_state hif_state;
 
 	u8 assoc_bssid[ETH_ALEN];
-	struct cfg_param_attr cfg_values;
 	/*lock to protect concurrent setting of cfg params*/
 	struct mutex cfg_values_lock;
 
-- 
2.17.1


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

* Re: [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work
  2018-11-06  0:01 ` [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work Adham.Abozaeid
@ 2018-11-07  8:46   ` kbuild test robot
  2018-11-08 11:22   ` Greg KH
  1 sibling, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2018-11-07  8:46 UTC (permalink / raw)
  To: Adham.Abozaeid
  Cc: kbuild-all, linux-wireless, devel, gregkh, johannes,
	Aditya.Shankar, Ganesh.Krishna

Hi Adham,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.20-rc1 next-20181106]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Adham-Abozaeid-microchip-com/staging-wilc1000-validate-input-to-set_wiphy_param-and-return-proper-errors/20181106-120308

smatch warnings:
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c:1152 set_wiphy_params() warn: always true condition '(wiphy->retry_short < 256) => (0-255 < 256)'
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c:1164 set_wiphy_params() warn: always true condition '(wiphy->retry_long < 256) => (0-255 < 256)'

vim +1152 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c

  1141	
  1142	static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
  1143	{
  1144		int ret;
  1145		struct cfg_param_attr cfg_param_val;
  1146		struct wilc_priv *priv = wiphy_priv(wiphy);
  1147		struct wilc_vif *vif = netdev_priv(priv->dev);
  1148	
  1149		cfg_param_val.flag = 0;
  1150	
  1151		if (changed & WIPHY_PARAM_RETRY_SHORT) {
> 1152			if (wiphy->retry_short > 0 && wiphy->retry_short < 256) {
  1153				netdev_dbg(vif->ndev,
  1154					   "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
  1155					   wiphy->retry_short);
  1156				cfg_param_val.flag  |= RETRY_SHORT;
  1157				cfg_param_val.short_retry_limit = wiphy->retry_short;
  1158			} else {
  1159				netdev_err(vif->ndev, "Short retry limit out of range\n");
  1160				return -EINVAL;
  1161			}
  1162		}
  1163		if (changed & WIPHY_PARAM_RETRY_LONG) {
> 1164			if (wiphy->retry_long > 0 && wiphy->retry_long < 256) {
  1165				netdev_dbg(vif->ndev,
  1166					   "Setting WIPHY_PARAM_RETRY_LONG %d\n",
  1167					   wiphy->retry_long);
  1168				cfg_param_val.flag |= RETRY_LONG;
  1169				cfg_param_val.long_retry_limit = wiphy->retry_long;
  1170			} else {
  1171				netdev_err(vif->ndev, "Long retry limit out of range\n");
  1172				return -EINVAL;
  1173			}
  1174		}
  1175		if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
  1176			if (wiphy->frag_threshold > 255 &&
  1177			    wiphy->frag_threshold < 7937) {
  1178				netdev_dbg(vif->ndev,
  1179					   "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n",
  1180					   wiphy->frag_threshold);
  1181				cfg_param_val.flag |= FRAG_THRESHOLD;
  1182				cfg_param_val.frag_threshold = wiphy->frag_threshold;
  1183			} else {
  1184				netdev_err(vif->ndev,
  1185					   "Fragmentation threshold out of range\n");
  1186				return -EINVAL;
  1187			}
  1188		}
  1189	
  1190		if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
  1191			if (wiphy->rts_threshold > 255) {
  1192				netdev_dbg(vif->ndev,
  1193					   "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n",
  1194					   wiphy->rts_threshold);
  1195				cfg_param_val.flag |= RTS_THRESHOLD;
  1196				cfg_param_val.rts_threshold = wiphy->rts_threshold;
  1197			} else {
  1198				netdev_err(vif->ndev, "RTS threshold out of range\n");
  1199				return -EINVAL;
  1200			}
  1201		}
  1202	
  1203		ret = wilc_hif_set_cfg(vif, &cfg_param_val);
  1204		if (ret)
  1205			netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n");
  1206	
  1207		return ret;
  1208	}
  1209	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

* Re: [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work
  2018-11-06  0:01 ` [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work Adham.Abozaeid
  2018-11-07  8:46   ` kbuild test robot
@ 2018-11-08 11:22   ` Greg KH
  2018-11-08 16:27     ` Adham.Abozaeid
  1 sibling, 1 reply; 8+ messages in thread
From: Greg KH @ 2018-11-08 11:22 UTC (permalink / raw)
  To: Adham.Abozaeid
  Cc: linux-wireless, devel, johannes, Aditya.Shankar, Ganesh.Krishna

On Tue, Nov 06, 2018 at 12:01:18AM +0000, Adham.Abozaeid@microchip.com wrote:
> From: Adham Abozaeid <adham.abozaeid@micochip.com>
> 
> Validate cfg parameters after being called by cfg80211 in set_wiphy_params
> before scheduling the work executed in handle_cfg_param
> 
> Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
> ---
>  drivers/staging/wilc1000/host_interface.c     | 61 ++++++-------------
>  .../staging/wilc1000/wilc_wfi_cfgoperations.c | 50 ++++++++++++---
>  2 files changed, 62 insertions(+), 49 deletions(-)

Please fix this up so that the 0-day bot does not complain about it.

thanks,

greg k-h

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

* Re: [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work
  2018-11-08 11:22   ` Greg KH
@ 2018-11-08 16:27     ` Adham.Abozaeid
  0 siblings, 0 replies; 8+ messages in thread
From: Adham.Abozaeid @ 2018-11-08 16:27 UTC (permalink / raw)
  To: gregkh; +Cc: linux-wireless, devel, johannes, Aditya.Shankar, Ganesh.Krishna


On 11/8/18 4:22 AM, Greg KH wrote:
> On Tue, Nov 06, 2018 at 12:01:18AM +0000, Adham.Abozaeid@microchip.com wrote:
>> From: Adham Abozaeid <adham.abozaeid@micochip.com>
>>
>> Validate cfg parameters after being called by cfg80211 in set_wiphy_params
>> before scheduling the work executed in handle_cfg_param
>>
>> Signed-off-by: Adham Abozaeid <adham.abozaeid@microchip.com>
>> ---
>>  drivers/staging/wilc1000/host_interface.c     | 61 ++++++-------------
>>  .../staging/wilc1000/wilc_wfi_cfgoperations.c | 50 ++++++++++++---
>>  2 files changed, 62 insertions(+), 49 deletions(-)
> Please fix this up so that the 0-day bot does not complain about it.

Sure Greg. I'll submit v4 with the fix for the bot warning.
I assume I shouldn't include patch 1/4 in the new version of the series since I see it was applied already, so I'll only resend the other 3 patches

Thanks,
Adham


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

end of thread, other threads:[~2018-11-08 16:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06  0:01 [PATCH v3 0/4] staging: wilc1000: validate input to set_wiphy_param and return proper errors Adham.Abozaeid
2018-11-06  0:01 ` [PATCH v3 1/4] staging: wilc1000: remove unused flags in handle_cfg_param() Adham.Abozaeid
2018-11-06  0:01 ` [PATCH v3 2/4] staging: wilc1000: validate cfg parameters before scheduling the work Adham.Abozaeid
2018-11-07  8:46   ` kbuild test robot
2018-11-08 11:22   ` Greg KH
2018-11-08 16:27     ` Adham.Abozaeid
2018-11-06  0:01 ` [PATCH v3 4/4] staging: wilc1000: Remove unused mutex cfg_values_lock Adham.Abozaeid
2018-11-06  0:01 ` [PATCH v3 3/4] staging: wilc1000: Don't keep a copy of wiphy parameters in the driver Adham.Abozaeid

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