Fix c90 errors

This commit is contained in:
Carlos Garces 2020-10-31 16:54:15 +01:00
parent 1628c748ce
commit b6a5f1bce9
2 changed files with 100 additions and 23 deletions

View File

@ -9,7 +9,7 @@ EXTRA_CFLAGS += -Wno-unused-label
EXTRA_CFLAGS += -Wno-unused-parameter EXTRA_CFLAGS += -Wno-unused-parameter
EXTRA_CFLAGS += -Wno-unused-function EXTRA_CFLAGS += -Wno-unused-function
EXTRA_CFLAGS += -Wno-unused EXTRA_CFLAGS += -Wno-unused
EXTRA_CFLAGS += -Wno-vla #EXTRA_CFLAGS += -Wno-vla
EXTRA_CFLAGS += -Wno-date-time EXTRA_CFLAGS += -Wno-date-time
GCC_VER_49 := $(shell echo `$(CC) -dumpversion | cut -f1-2 -d.` \>= 4.9 | bc ) GCC_VER_49 := $(shell echo `$(CC) -dumpversion | cut -f1-2 -d.` \>= 4.9 | bc )

View File

@ -24,6 +24,18 @@
#include <rtw_bt_mp.h> #include <rtw_bt_mp.h>
#endif #endif
#define RTW_IWD_MAX_LEN 128
inline u8 rtw_do_mp_iwdata_len_chk(const char *caller, u32 len)
{
u8 is_illegal = _FALSE;
if (len >= RTW_IWD_MAX_LEN) {
RTW_ERR("%s : iw data len(%u) > RTW_IWD_MAX_LEN(%u)",
caller, len, RTW_IWD_MAX_LEN);
is_illegal = _TRUE;
}
return is_illegal;
}
/* /*
* Input Format: %s,%d,%d * Input Format: %s,%d,%d
* %s is width, could be * %s is width, could be
@ -43,7 +55,10 @@ int rtw_mp_write_reg(struct net_device *dev,
u32 addr, data; u32 addr, data;
int ret; int ret;
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
char input[wrqu->length + 1]; char input[RTW_IWD_MAX_LEN];
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
@ -129,7 +144,7 @@ int rtw_mp_read_reg(struct net_device *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
char input[wrqu->length + 1]; char input[RTW_IWD_MAX_LEN];
char *pch, *pnext; char *pch, *pnext;
char *width_str; char *width_str;
char width; char width;
@ -139,6 +154,9 @@ int rtw_mp_read_reg(struct net_device *dev,
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
char *pextra = extra; char *pextra = extra;
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
if (wrqu->length > 128) if (wrqu->length > 128)
return -EFAULT; return -EFAULT;
@ -263,8 +281,10 @@ int rtw_mp_write_rf(struct net_device *dev,
u32 path, addr, data; u32 path, addr, data;
int ret; int ret;
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
char input[wrqu->length]; char input[RTW_IWD_MAX_LEN];
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
_rtw_memset(input, 0, wrqu->length); _rtw_memset(input, 0, wrqu->length);
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
@ -305,7 +325,7 @@ int rtw_mp_read_rf(struct net_device *dev,
struct iw_request_info *info, struct iw_request_info *info,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
char input[wrqu->length]; char input[RTW_IWD_MAX_LEN];
char *pch, *pnext; char *pch, *pnext;
char data[20], tmp[20]; char data[20], tmp[20];
u32 path, addr, strtou; u32 path, addr, strtou;
@ -313,6 +333,9 @@ int rtw_mp_read_rf(struct net_device *dev,
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
char *pextra = extra; char *pextra = extra;
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (wrqu->length > 128) if (wrqu->length > 128)
return -EFAULT; return -EFAULT;
_rtw_memset(input, 0, wrqu->length); _rtw_memset(input, 0, wrqu->length);
@ -410,10 +433,13 @@ int rtw_mp_rate(struct net_device *dev,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
u32 rate = MPT_RATE_1M; u32 rate = MPT_RATE_1M;
u8 input[wrqu->length + 1]; u8 input[RTW_IWD_MAX_LEN];
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
PMPT_CONTEXT pMptCtx = &(padapter->mppriv.mpt_ctx); PMPT_CONTEXT pMptCtx = &(padapter->mppriv.mpt_ctx);
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -460,9 +486,12 @@ int rtw_mp_channel(struct net_device *dev,
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
u8 input[wrqu->length + 1]; u8 input[RTW_IWD_MAX_LEN];
u32 channel = 1; u32 channel = 1;
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -487,9 +516,12 @@ int rtw_mp_ch_offset(struct net_device *dev,
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
u8 input[wrqu->length + 1]; u8 input[RTW_IWD_MAX_LEN];
u32 ch_offset = 0; u32 ch_offset = 0;
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -514,7 +546,10 @@ int rtw_mp_bandwidth(struct net_device *dev,
u32 bandwidth = 0, sg = 0; u32 bandwidth = 0, sg = 0;
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
u8 input[wrqu->length]; u8 input[RTW_IWD_MAX_LEN];
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -547,10 +582,13 @@ int rtw_mp_txpower_index(struct net_device *dev,
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
HAL_DATA_TYPE *phal_data = GET_HAL_DATA(padapter); HAL_DATA_TYPE *phal_data = GET_HAL_DATA(padapter);
char input[wrqu->length + 1]; char input[RTW_IWD_MAX_LEN];
u32 rfpath; u32 rfpath;
u32 txpower_inx; u32 txpower_inx;
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
if (wrqu->length > 128) if (wrqu->length > 128)
return -EFAULT; return -EFAULT;
@ -593,11 +631,14 @@ int rtw_mp_txpower(struct net_device *dev,
{ {
u32 idx_a = 0, idx_b = 0, idx_c = 0, idx_d = 0; u32 idx_a = 0, idx_b = 0, idx_c = 0, idx_d = 0;
int MsetPower = 1; int MsetPower = 1;
u8 input[wrqu->length]; u8 input[RTW_IWD_MAX_LEN];
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
PMPT_CONTEXT pMptCtx = &(padapter->mppriv.mpt_ctx); PMPT_CONTEXT pMptCtx = &(padapter->mppriv.mpt_ctx);
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -631,11 +672,14 @@ int rtw_mp_ant_tx(struct net_device *dev,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
u8 i; u8 i;
u8 input[wrqu->length + 1]; u8 input[RTW_IWD_MAX_LEN];
u16 antenna = 0; u16 antenna = 0;
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -679,10 +723,13 @@ int rtw_mp_ant_rx(struct net_device *dev,
{ {
u8 i; u8 i;
u16 antenna = 0; u16 antenna = 0;
u8 input[wrqu->length + 1]; u8 input[RTW_IWD_MAX_LEN];
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -859,9 +906,12 @@ int rtw_mp_disable_bt_coexist(struct net_device *dev,
PADAPTER padapter = (PADAPTER)rtw_netdev_priv(dev); PADAPTER padapter = (PADAPTER)rtw_netdev_priv(dev);
#endif #endif
u8 input[wrqu->data.length + 1]; u8 input[RTW_IWD_MAX_LEN];
u32 bt_coexist; u32 bt_coexist;
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->data.length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length))
@ -897,13 +947,16 @@ int rtw_mp_arx(struct net_device *dev,
{ {
int bStartRx = 0, bStopRx = 0, bQueryPhy = 0, bQueryMac = 0, bSetBssid = 0, bSetRxframe = 0; int bStartRx = 0, bStopRx = 0, bQueryPhy = 0, bQueryMac = 0, bSetBssid = 0, bSetRxframe = 0;
int bmac_filter = 0, bmon = 0, bSmpCfg = 0; int bmac_filter = 0, bmon = 0, bSmpCfg = 0;
u8 input[wrqu->length]; u8 input[RTW_IWD_MAX_LEN];
char *pch, *token, *tmp[2] = {0x00, 0x00}; char *pch, *token, *tmp[2] = {0x00, 0x00};
u32 i = 0, jj = 0, kk = 0, cnts = 0, ret; u32 i = 0, jj = 0, kk = 0, cnts = 0, ret;
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
struct mp_priv *pmppriv = &padapter->mppriv; struct mp_priv *pmppriv = &padapter->mppriv;
struct dbg_rx_counter rx_counter; struct dbg_rx_counter rx_counter;
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -1082,7 +1135,10 @@ int rtw_mp_pwrtrk(struct net_device *dev,
u32 thermal; u32 thermal;
s32 ret; s32 ret;
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
u8 input[wrqu->length]; u8 input[RTW_IWD_MAX_LEN];
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -1120,7 +1176,10 @@ int rtw_mp_psd(struct net_device *dev,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
u8 input[wrqu->length + 1]; u8 input[RTW_IWD_MAX_LEN];
if (rtw_do_mp_iwdata_len_chk(__func__, (wrqu->length + 1)))
return -EFAULT;
_rtw_memset(input, 0, sizeof(input)); _rtw_memset(input, 0, sizeof(input));
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
@ -1241,11 +1300,15 @@ int rtw_mp_dump(struct net_device *dev,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
struct mp_priv *pmp_priv; struct mp_priv *pmp_priv;
u8 input[wrqu->length]; u8 input[RTW_IWD_MAX_LEN];
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
pmp_priv = &padapter->mppriv; pmp_priv = &padapter->mppriv;
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -1265,9 +1328,12 @@ int rtw_mp_phypara(struct net_device *dev,
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
char input[wrqu->length]; char input[RTW_IWD_MAX_LEN];
u32 valxcap, ret; u32 valxcap, ret;
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -1291,7 +1357,7 @@ int rtw_mp_SetRFPath(struct net_device *dev,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
char input[wrqu->length]; char input[RTW_IWD_MAX_LEN];
int bMain = 1, bTurnoff = 1; int bMain = 1, bTurnoff = 1;
#ifdef CONFIG_ANTENNA_DIVERSITY #ifdef CONFIG_ANTENNA_DIVERSITY
u8 ret = _TRUE; u8 ret = _TRUE;
@ -1299,6 +1365,9 @@ int rtw_mp_SetRFPath(struct net_device *dev,
RTW_INFO("%s:iwpriv in=%s\n", __func__, input); RTW_INFO("%s:iwpriv in=%s\n", __func__, input);
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -1342,10 +1411,12 @@ int rtw_mp_switch_rf_path(struct net_device *dev,
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
struct mp_priv *pmp_priv; struct mp_priv *pmp_priv;
char input[wrqu->length]; char input[RTW_IWD_MAX_LEN];
int bwlg = 1, bwla = 1, btg = 1, bbt=1; int bwlg = 1, bwla = 1, btg = 1, bbt=1;
u8 ret = 0; u8 ret = 0;
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;
@ -1391,11 +1462,14 @@ int rtw_mp_QueryDrv(struct net_device *dev,
union iwreq_data *wrqu, char *extra) union iwreq_data *wrqu, char *extra)
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
char input[wrqu->data.length]; char input[RTW_IWD_MAX_LEN];
int qAutoLoad = 1; int qAutoLoad = 1;
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter); PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->data.length))
return -EFAULT;
if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length))
return -EFAULT; return -EFAULT;
RTW_INFO("%s:iwpriv in=%s\n", __func__, input); RTW_INFO("%s:iwpriv in=%s\n", __func__, input);
@ -1420,9 +1494,12 @@ int rtw_mp_PwrCtlDM(struct net_device *dev,
struct iw_point *wrqu, char *extra) struct iw_point *wrqu, char *extra)
{ {
PADAPTER padapter = rtw_netdev_priv(dev); PADAPTER padapter = rtw_netdev_priv(dev);
u8 input[wrqu->length]; u8 input[RTW_IWD_MAX_LEN];
int bstart = 1; int bstart = 1;
if (rtw_do_mp_iwdata_len_chk(__func__, wrqu->length))
return -EFAULT;
if (copy_from_user(input, wrqu->pointer, wrqu->length)) if (copy_from_user(input, wrqu->pointer, wrqu->length))
return -EFAULT; return -EFAULT;