mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-25 11:55:37 +00:00
staging: wilc1000: validate cfg parameters before scheduling the work
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
056ef75860
commit
6eb7207384
2 changed files with 48 additions and 45 deletions
|
@ -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 *)¶m->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 *)¶m->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 *)¶m->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 *)¶m->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 *)¶m->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 *)¶m->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 *)¶m->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 *)¶m->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);
|
||||
}
|
||||
|
|
|
@ -1149,21 +1149,45 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
|
|||
cfg_param_val.flag = 0;
|
||||
|
||||
if (changed & WIPHY_PARAM_RETRY_SHORT) {
|
||||
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;
|
||||
}
|
||||
if (changed & WIPHY_PARAM_RETRY_LONG) {
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue