diff options
| author | fire855 <thefire855@gmail.com> | 2016-07-11 23:44:28 +0200 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2016-08-26 16:02:19 +0200 |
| commit | baa75193e3edc154e5fb3a4cd970a1950e1c5a73 (patch) | |
| tree | bb372c64f9533864dbc81e6acedd8ce5fe05d324 | |
| parent | 762f5b74c7428e76566cbaa4edba9c0afac53b6b (diff) | |
Fix "stack overflow in Mediatek WIFI driver" issue Based on: https://android.googlesource.com/kernel/mediatek/+/13a29ccea87ae65cbaaa40f22a16469cd5cd8c27
| -rw-r--r-- | drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_p2p.c | 824 |
1 files changed, 3 insertions, 821 deletions
diff --git a/drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_p2p.c b/drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_p2p.c index 2797ece81..1fff7310d 100644 --- a/drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_p2p.c +++ b/drivers/misc/mediatek/connectivity/conn_soc/drv_wlan/mt_wifi/wlan/os/linux/gl_p2p.c @@ -3474,158 +3474,6 @@ mtk_p2p_wext_discovery_results( IN OUT char *extra ) { - struct iw_event iwe; - char *current_ev = extra; - UINT_32 i; - P_GLUE_INFO_T prGlueInfo = NULL; - P_ADAPTER_T prAdapter = NULL; - P_P2P_INFO_T prP2PInfo = (P_P2P_INFO_T)NULL; - P_EVENT_P2P_DEV_DISCOVER_RESULT_T prTargetResult = (P_EVENT_P2P_DEV_DISCOVER_RESULT_T)NULL; - P_PARAM_VARIABLE_IE_T prDesiredIE = NULL; - - ASSERT(prDev); - - prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); - ASSERT(prGlueInfo); - - prAdapter = prGlueInfo->prAdapter; - ASSERT(prAdapter); - - prP2PInfo = prAdapter->prP2pInfo; - - for(i = 0 ; i < prP2PInfo->u4DeviceNum ; i++) { - prTargetResult = &prP2PInfo->arP2pDiscoverResult[i]; - - /* SIOCGIWAP */ - iwe.cmd = SIOCGIWAP; - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - memcpy(iwe.u.ap_addr.sa_data, - prTargetResult->aucInterfaceAddr, - 6); - - current_ev = iwe_stream_add_event(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, IW_EV_ADDR_LEN); - - - /* SIOCGIWESSID */ - iwe.cmd = SIOCGIWESSID; - iwe.u.data.flags = 1; - iwe.u.data.length = prTargetResult->u2NameLength; - - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, prTargetResult->aucName); - - /* IWEVGENIE for WPA IE */ - if(prTargetResult->u2IELength <= 600 && wextSrchDesiredWPAIE(prTargetResult->pucIeBuf, - prTargetResult->u2IELength, - 0xDD, - (PUINT_8 *)&prDesiredIE)) { - - iwe.cmd = IWEVGENIE; - iwe.u.data.flags = 1; - iwe.u.data.length = 2 + (__u16)prDesiredIE->ucLength; - - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, (char *)prDesiredIE); - } - -#if CFG_SUPPORT_WPS - - /* IWEVGENIE for WPS IE */ - if((prTargetResult->u2IELength <= 600) && wextSrchDesiredWPSIE(prTargetResult->pucIeBuf, - prTargetResult->u2IELength, - 0xDD, - (PUINT_8 *)&prDesiredIE)) { - - iwe.cmd = IWEVGENIE; - iwe.u.data.flags = 1; - iwe.u.data.length = 2 + (__u16)prDesiredIE->ucLength; - - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, (char *)prDesiredIE); - } - -#endif - - /* IWEVGENIE for RSN IE */ - if((prTargetResult->u2IELength <= 600) && wextSrchDesiredWPAIE(prTargetResult->pucIeBuf, - prTargetResult->u2IELength, - 0x30, - (PUINT_8 *)&prDesiredIE)) { - - iwe.cmd = IWEVGENIE; - iwe.u.data.flags = 1; - iwe.u.data.length = 2 + (__u16)prDesiredIE->ucLength; - - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, (char *)prDesiredIE); - } - - /* IOC_P2P_GO_WSC_IE */ -#if 1 - /* device capability */ - if (1) { - UINT_8 data[40]; - - iwe.cmd = IWEVCUSTOM; - iwe.u.data.flags = 0; - iwe.u.data.length = 8 + sizeof("p2p_cap="); - if (iwe.u.data.length > 40) - iwe.u.data.length = 40; - - snprintf(data, iwe.u.data.length, "p2p_cap=%02x%02x%02x%02x%c", - prTargetResult->ucDeviceCapabilityBitmap, prTargetResult->ucGroupCapabilityBitmap, - (UINT_8)prTargetResult->u2ConfigMethod, (UINT_8)(prTargetResult->u2ConfigMethod >> 8), '\0' ); - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, (char *)data); - - //printk("%s\n", data); - kalMemZero(data, 40); - - iwe.cmd = IWEVCUSTOM; - iwe.u.data.flags = 0; - iwe.u.data.length = 12 + sizeof("p2p_dev_type="); - if (iwe.u.data.length > 40) - iwe.u.data.length = 40; - - snprintf(data, iwe.u.data.length, "p2p_dev_type=%02x%02x%02x%02x%02x%02x%c", - (UINT_8)prTargetResult->rPriDevType.u2CategoryID,(UINT_8)prTargetResult->rPriDevType.u2SubCategoryID, - (UINT_8)prTargetResult->arSecDevType[0].u2CategoryID,(UINT_8)prTargetResult->arSecDevType[0].u2SubCategoryID, - (UINT_8)prTargetResult->arSecDevType[1].u2CategoryID,(UINT_8)prTargetResult->arSecDevType[1].u2SubCategoryID, - '\0'); - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, (char *)data); - //printk("%s\n", data); - - kalMemZero(data, 40); - - iwe.cmd = IWEVCUSTOM; - iwe.u.data.flags = 0; - iwe.u.data.length = 17 + sizeof("p2p_grp_bssid="); - if (iwe.u.data.length > 40) - iwe.u.data.length = 40; - - snprintf(data, iwe.u.data.length, "p2p_grp_bssid="MACSTR"%c", - MAC2STR(prTargetResult->aucBSSID), '\0'); - current_ev = iwe_stream_add_point(info, current_ev, - extra + IW_SCAN_MAX_DATA, - &iwe, (char *)data); - //printk("%s\n", data); - - } -#endif - } - - /* Length of data */ - wrqu->data.length = (current_ev - extra); - wrqu->data.flags = 0; return 0; } /* end of mtk_p2p_wext_discovery_results() */ @@ -3653,38 +3501,6 @@ mtk_p2p_wext_wsc_ie( IN OUT char *extra ) { - P_ADAPTER_T prAdapter = NULL; - P_GLUE_INFO_T prGlueInfo = NULL; - P_IW_P2P_HOSTAPD_PARAM prHostapdParam = (P_IW_P2P_HOSTAPD_PARAM)extra; - - ASSERT(prDev); - - prGlueInfo = *((P_GLUE_INFO_T *)netdev_priv(prDev)); - ASSERT(prGlueInfo); - - if (prHostapdParam->len > 0) { - if (prHostapdParam->len <= MAX_WSC_IE_LENGTH) { - if (copy_from_user(prGlueInfo->prP2PInfo->aucWSCIE[0], prHostapdParam->data, prHostapdParam->len)) { - return -EFAULT; - } - if (copy_from_user(prGlueInfo->prP2PInfo->aucWSCIE[2], prHostapdParam->data, prHostapdParam->len)) { - return -EFAULT; - } - } - else { - return -E2BIG; - } - } - - prGlueInfo->prP2PInfo->u2WSCIELen[0] = prHostapdParam->len; - prGlueInfo->prP2PInfo->u2WSCIELen[2] = prHostapdParam->len; - - prAdapter = prGlueInfo->prAdapter; - ASSERT(prAdapter); - - bssUpdateBeaconContent(prAdapter, NETWORK_TYPE_P2P_INDEX); - - //@TODO: send message to P2P-FSM return 0; } /* end of mtk_p2p_wext_wsc_ie() */ @@ -3712,67 +3528,6 @@ mtk_p2p_wext_connect_disconnect( IN OUT char *extra ) { - P_ADAPTER_T prAdapter = NULL; - P_GLUE_INFO_T prGlueInfo = NULL; - struct iw_point *prData= (struct iw_point *)&wrqu->data; -// P_IW_P2P_CONNECT_DEVICE prConnectDevice = (P_IW_P2P_CONNECT_DEVICE)extra; -// P_MSG_HDR_T prMsgHdr; -// P_MSG_P2P_CONNECTION_REQUEST_T prMsgP2PConnReq; -// P_MSG_P2P_CONNECTION_ABORT_T prMsgP2PConnAbt; -// UINT_8 aucBCAddr[] = BC_MAC_ADDR; - - ASSERT(prDev); - - prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); - ASSERT(prGlueInfo); - - prAdapter = prGlueInfo->prAdapter; - ASSERT(prAdapter); - - if (prData->flags == P2P_CONNECT) { -#if 0 - // indicate P2P-FSM with MID_MNY_P2P_CONNECTION_REQ - prMsgP2PConnReq = (P_MSG_P2P_CONNECTION_REQUEST_T) cnmMemAlloc(prAdapter, - RAM_TYPE_MSG, - sizeof(MSG_P2P_CONNECTION_REQUEST_T)); - - if (!prMsgP2PConnReq) { - ASSERT(0); // Can't trigger P2P FSM - return -ENOMEM; - } - - - mboxSendMsg(prAdapter, - MBOX_ID_0, - (P_MSG_HDR_T) prMsgP2PConnReq, - MSG_SEND_METHOD_BUF); -#endif - } - else if(prData->flags == P2P_DISCONNECT) { -#if 0 - // indicate P2P-FSM with MID_MNY_P2P_CONNECTION_ABORT - prMsgP2PConnAbt = (P_MSG_HDR_T) cnmMemAlloc(prAdapter, - RAM_TYPE_MSG, - sizeof(MSG_P2P_CONNECTION_ABORT_T)); - - if (!prMsgP2PConnAbt) { - ASSERT(0); // Can't trigger P2P FSM - return -ENOMEM; - } - - COPY_MAC_ADDR(prMsgP2PConnAbt->aucTargetID, prConnectDevice->sta_addr); - - prMsgP2PConnAbt->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_ABORT; - - mboxSendMsg(prAdapter, - MBOX_ID_0, - (P_MSG_HDR_T) prMsgP2PConnAbt, - MSG_SEND_METHOD_BUF); -#endif - } - else { - return -EINVAL; - } return 0; } /* end of mtk_p2p_wext_connect_disconnect() */ @@ -3800,67 +3555,7 @@ mtk_p2p_wext_password_ready( IN OUT char *extra ) { - P_ADAPTER_T prAdapter = NULL; - P_GLUE_INFO_T prGlueInfo = NULL; - P_IW_P2P_PASSWORD_READY prPasswordReady = (P_IW_P2P_PASSWORD_READY)extra; - P_P2P_CONNECTION_SETTINGS_T prConnSettings; - UINT_16 u2CmdLen = 0; - - ASSERT(prDev); - prGlueInfo = *((P_GLUE_INFO_T *)netdev_priv(prDev)); - ASSERT(prGlueInfo); - - prAdapter = prGlueInfo->prAdapter; - ASSERT(prAdapter); - - prConnSettings = prAdapter->rWifiVar.prP2PConnSettings; - u2CmdLen = prPasswordReady->probe_req_len; - - /* retrieve IE for Probe Request */ - if (u2CmdLen > 0) { - if (u2CmdLen <= MAX_WSC_IE_LENGTH) { - if (copy_from_user(prGlueInfo->prP2PInfo->aucWSCIE[1], prPasswordReady->probe_req_ie, u2CmdLen)) { - return -EFAULT; - } - } - else { - return -E2BIG; - } - } - - prGlueInfo->prP2PInfo->u2WSCIELen[1] = u2CmdLen; - - /* retrieve IE for Probe Response */ - u2CmdLen = prPasswordReady->probe_rsp_len; - if (u2CmdLen > 0) { - if (u2CmdLen <= MAX_WSC_IE_LENGTH) { - if (copy_from_user(prGlueInfo->prP2PInfo->aucWSCIE[2], prPasswordReady->probe_rsp_ie, u2CmdLen)) { - return -EFAULT; - } - } - else { - return -E2BIG; - } - } - - prGlueInfo->prP2PInfo->u2WSCIELen[2] = u2CmdLen; - - switch (prPasswordReady->active_config_method) { - case 1: - prConnSettings->u2LocalConfigMethod = WPS_ATTRI_CFG_METHOD_PUSH_BUTTON; - break; - case 2: - prConnSettings->u2LocalConfigMethod = WPS_ATTRI_CFG_METHOD_KEYPAD; - break; - case 3: - prConnSettings->u2LocalConfigMethod = WPS_ATTRI_CFG_METHOD_DISPLAY; - break; - default: - break; - } - - prConnSettings->fgIsPasswordIDRdy = TRUE; return 0; } /* end of mtk_p2p_wext_password_ready() */ @@ -3887,29 +3582,6 @@ mtk_p2p_wext_request_dev_info( IN OUT char *extra ) { - P_ADAPTER_T prAdapter = NULL; - P_GLUE_INFO_T prGlueInfo = NULL; - P_IW_P2P_DEVICE_REQ prDeviceReq = (P_IW_P2P_DEVICE_REQ)extra; - - ASSERT(prDev); - - prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); - ASSERT(prGlueInfo); - - prAdapter = prGlueInfo->prAdapter; - ASSERT(prAdapter); - - // specify data length - wrqu->data.length = sizeof(IW_P2P_DEVICE_REQ); - - // copy to upper-layer supplied buffer - kalMemCopy(prDeviceReq->name, prGlueInfo->prP2PInfo->aucConnReqDevName, prGlueInfo->prP2PInfo->u4ConnReqNameLength); - prDeviceReq->name_len = prGlueInfo->prP2PInfo->u4ConnReqNameLength; - prDeviceReq->name[prDeviceReq->name_len]='\0'; - COPY_MAC_ADDR(prDeviceReq->device_addr, prGlueInfo->prP2PInfo->rConnReqPeerAddr); - prDeviceReq->device_type = prGlueInfo->prP2PInfo->ucConnReqDevType; - prDeviceReq->config_method = prGlueInfo->prP2PInfo->i4ConnReqConfigMethod; - prDeviceReq->active_config_method = prGlueInfo->prP2PInfo->i4ConnReqActiveConfigMethod; return 0; } /* end of mtk_p2p_wext_request_dev_info() */ @@ -4234,132 +3906,8 @@ mtk_p2p_wext_set_int ( IN OUT char *extra ) { - int status = 0; - UINT_32 u4SubCmd = 0; - P_GLUE_INFO_T prGlueInfo = NULL; - UINT_32 index; - INT_32 value; - PUINT_32 pu4IntBuf; - P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL; - P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL; - P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL; - UINT_32 u4Leng; - - ASSERT(prDev); - ASSERT(wrqu); - - //printk("mtk_p2p_wext_set_int\n"); - pu4IntBuf = (PUINT_32) extra; - - if (FALSE == GLUE_CHK_PR2(prDev, wrqu)) { - return -EINVAL; - } - - prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); - ASSERT(prGlueInfo); - prP2pSpecificBssInfo = prGlueInfo->prAdapter->rWifiVar.prP2pSpecificBssInfo; - prP2pConnSettings = prGlueInfo->prAdapter->rWifiVar.prP2PConnSettings; - prP2pFsmInfo = prGlueInfo->prAdapter->rWifiVar.prP2pFsmInfo; - - u4SubCmd = (UINT_32) wrqu->mode; - index = pu4IntBuf[1]; - value = pu4IntBuf[2]; - - printk("set parameter, u4SubCmd=%d idx=%d value=%d\n", (INT_16)u4SubCmd, (INT_16)index, value); - - switch (u4SubCmd) { - case PRIV_CMD_INT_P2P_SET: - switch (index) { - case 0: /* Listen CH */ - { - UINT_8 ucSuggestChnl = 0; - - prP2pConnSettings->ucListenChnl = value; - - // 20110920 - frog: User configurations are placed in ConnSettings. - if (rlmFuncFindAvailableChannel(prGlueInfo->prAdapter, value, &ucSuggestChnl, TRUE, TRUE)) { - prP2pSpecificBssInfo->ucListenChannel = value; - } - else { - prP2pSpecificBssInfo->ucListenChannel = ucSuggestChnl; - } - - - break; - } - case 1: /* P2p mode */ - break; - case 4: /* Noa duration */ - prP2pSpecificBssInfo->rNoaParam.u4NoaDurationMs = value; - // only to apply setting when setting NOA count - //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam); - break; - case 5: /* Noa interval */ - prP2pSpecificBssInfo->rNoaParam.u4NoaIntervalMs = value; - // only to apply setting when setting NOA count - //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam); - break; - case 6: /* Noa count */ - prP2pSpecificBssInfo->rNoaParam.u4NoaCount = value; - status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam); - break; - case 100: /* Oper CH */ - // 20110920 - frog: User configurations are placed in ConnSettings. - prP2pConnSettings->ucOperatingChnl = value; - break; - case 101: /* Local config Method, for P2P SDK */ - //prP2pConnSettings->u2LocalConfigMethod; - break; - case 102: /* Sigma P2p reset */ - kalMemZero(prP2pConnSettings->aucTargetDevAddr, MAC_ADDR_LEN); - //prP2pConnSettings->eConnectionPolicy = ENUM_P2P_CONNECTION_POLICY_AUTO; - break; - case 103: /* WPS MODE */ - kalP2PSetWscMode(prGlueInfo, value); - break; - case 104: /* P2p send persence, duration */ - break; - case 105: /* P2p send persence, interval */ - break; - case 106: /* P2P set sleep */ - value = 1; - kalIoctl(prGlueInfo, - wlanoidSetP2pPowerSaveProfile, - &value, - sizeof(value), - FALSE, - FALSE, - TRUE, - TRUE, - &u4Leng); - break; - case 107: /* P2P set opps, CTWindowl */ - prP2pSpecificBssInfo->rOppPsParam.u4CTwindowMs = value; - status = mtk_p2p_wext_set_oppps_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rOppPsParam); - break; - case 108: /* p2p_set_power_save */ - kalIoctl(prGlueInfo, - wlanoidSetP2pPowerSaveProfile, - &value, - sizeof(value), - FALSE, - FALSE, - TRUE, - TRUE, - &u4Leng); - - break; - - default: - break; - } - break; - default: - break; - } - - return status; + return 0; } /*----------------------------------------------------------------------------*/ @@ -4384,153 +3932,8 @@ mtk_p2p_wext_set_struct ( IN OUT char *extra ) { - int status = 0; - UINT_32 u4SubCmd = 0; - UINT_32 u4CmdLen = 0; - P_GLUE_INFO_T prGlueInfo = NULL; - P_IW_P2P_TRANSPORT_STRUCT prP2PReq = NULL; - - ASSERT(prDev); - ASSERT(wrqu); - - if (FALSE == GLUE_CHK_PR2(prDev, wrqu)) { - return -EINVAL; - } - - prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); - ASSERT(prGlueInfo); - - u4SubCmd = (UINT_32) wrqu->data.flags; - u4CmdLen = wrqu->data.length; - - kalMemZero(&prGlueInfo->prP2PInfo->aucOidBuf[0], - sizeof(prGlueInfo->prP2PInfo->aucOidBuf)); - - switch (u4SubCmd) { - case PRIV_CMD_OID: - if (u4CmdLen > OID_SET_GET_STRUCT_LENGTH) { - printk(KERN_INFO DRV_NAME"input data length invalid %ld\n", u4CmdLen); - status = -EINVAL; - break; - } - - if (copy_from_user(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), - wrqu->data.pointer, - u4CmdLen)) { - status = -EFAULT; - break; - } - if (!kalMemCmp(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), extra, u4CmdLen)) { - printk(KERN_INFO DRV_NAME"extra buffer is valid\n"); - } - else { - printk(KERN_INFO DRV_NAME"extra 0x%p\n", extra); - } - - prP2PReq = (P_IW_P2P_TRANSPORT_STRUCT) (&(prGlueInfo->prP2PInfo->aucOidBuf[0])); - switch(prP2PReq->u4CmdId) { - case P2P_CMD_ID_SEND_SD_RESPONSE: - status = mtk_p2p_wext_send_service_discovery_response(prDev, info, wrqu, (char *)prP2PReq); - break; - - case P2P_CMD_ID_SEND_SD_REQUEST: - status = mtk_p2p_wext_send_service_discovery_request(prDev, info, wrqu, (char *)prP2PReq); - break; - - case P2P_CMD_ID_TERMINATE_SD_PHASE: - status = mtk_p2p_wext_terminate_service_discovery_phase(prDev, info, wrqu, (char *)prP2PReq); - break; - - case P2P_CMD_ID_INVITATION: - if (prP2PReq->inBufferLength == sizeof(IW_P2P_IOCTL_INVITATION_STRUCT)) { -// status = mtk_p2p_wext_invitation_request(prDev, info, wrqu, (char *)(prP2PReq->aucBuffer)); - } - break; - - case P2P_CMD_ID_INVITATION_ABORT: - if (prP2PReq->inBufferLength == sizeof(IW_P2P_IOCTL_ABORT_INVITATION)) { -// status = mtk_p2p_wext_invitation_abort(prDev, info, wrqu, (char *)(prP2PReq->aucBuffer)); - } - break; - - case P2P_CMD_ID_START_FORMATION: - if (prP2PReq->inBufferLength == sizeof(IW_P2P_IOCTL_START_FORMATION)) { - status = mtk_p2p_wext_start_formation(prDev, info, wrqu, (char *)(prP2PReq->aucBuffer)); - } - break; - default: - status = -EOPNOTSUPP; - } - - break; -#if CFG_SUPPORT_ANTI_PIRACY - case PRIV_SEC_CHECK_OID: - if (u4CmdLen > 256) { - status = -EOPNOTSUPP; - break; - } - if (copy_from_user(&(prGlueInfo->prP2PInfo->aucSecCheck[0]), - wrqu->data.pointer, - u4CmdLen)) { - status = -EFAULT; - break; - } - - if (!kalMemCmp(&(prGlueInfo->prP2PInfo->aucSecCheck[0]), extra, u4CmdLen)) { - printk(KERN_INFO DRV_NAME"extra buffer is valid\n"); - } - else { - printk(KERN_INFO DRV_NAME"extra 0x%p\n", extra); - } - prP2PReq = (P_IW_P2P_TRANSPORT_STRUCT) (&(prGlueInfo->prP2PInfo->aucSecCheck[0])); - - switch(prP2PReq->u4CmdId) { - case P2P_CMD_ID_SEC_CHECK: - status = mtk_p2p_wext_set_sec_check_request(prDev, info, wrqu, (char *)prP2PReq); - break; - default: - status = -EOPNOTSUPP; - } - break; -#endif - case PRIV_CMD_P2P_VERSION: - if (u4CmdLen > OID_SET_GET_STRUCT_LENGTH) { - printk(KERN_INFO DRV_NAME"input data length invalid %ld\n", u4CmdLen); - status = -EINVAL; - break; - } - - if (copy_from_user(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), - wrqu->data.pointer, - u4CmdLen)) { - status = -EFAULT; - break; - } - - if (!kalMemCmp(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), extra, u4CmdLen)) { - printk(KERN_INFO DRV_NAME"extra buffer is valid\n"); - } - else { - printk(KERN_INFO DRV_NAME"extra 0x%p\n", extra); - } - - prP2PReq = (P_IW_P2P_TRANSPORT_STRUCT) (&(prGlueInfo->prP2PInfo->aucOidBuf[0])); - switch (prP2PReq->u4CmdId) { - case P2P_CMD_ID_P2P_VERSION: - status = mtk_p2p_wext_set_p2p_version(prDev, info, wrqu, (char *)prP2PReq); - break; - default: - status = -EOPNOTSUPP; - break; - } - break; - default: - status = -EOPNOTSUPP; - break; - } - - return status; + return 0; } @@ -4556,229 +3959,8 @@ mtk_p2p_wext_get_struct ( IN OUT char *extra ) { - int status = 0; - UINT_32 u4SubCmd = 0; - UINT_32 u4CmdLen = 0; - P_GLUE_INFO_T prGlueInfo = NULL; - P_IW_P2P_TRANSPORT_STRUCT prP2PReq = NULL; - - ASSERT(prDev); - ASSERT(wrqu); - if (!prDev || !wrqu) { - printk(KERN_INFO DRV_NAME "%s(): invalid param(0x%p, 0x%p)\n", - __func__, - prDev, - wrqu); - return -EINVAL; - } - - prGlueInfo = *((P_GLUE_INFO_T *) netdev_priv(prDev)); - ASSERT(prGlueInfo); - - u4SubCmd = (UINT_32) wrqu->data.flags; - u4CmdLen = wrqu->data.length; - - kalMemZero(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), - sizeof(prGlueInfo->prP2PInfo->aucOidBuf)); - - switch (u4SubCmd) { - case PRIV_CMD_OID: - if (u4CmdLen > sizeof(IW_P2P_TRANSPORT_STRUCT)) { - printk(KERN_INFO DRV_NAME"input data length invalid %ld\n", u4CmdLen); - status = -EINVAL; - break; - } - - if (copy_from_user(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), - wrqu->data.pointer, - sizeof(IW_P2P_TRANSPORT_STRUCT))) { - printk(KERN_NOTICE "%s() copy_from_user oidBuf fail\n", __func__); - return -EFAULT; - } - - prP2PReq = (P_IW_P2P_TRANSPORT_STRUCT) (&(prGlueInfo->prP2PInfo->aucOidBuf[0])); - - switch(prP2PReq->u4CmdId) { - case P2P_CMD_ID_GET_SD_REQUEST: - status = mtk_p2p_wext_get_service_discovery_request(prDev, info, wrqu, (char *)prP2PReq); - break; - - case P2P_CMD_ID_GET_SD_RESPONSE: - status = mtk_p2p_wext_get_service_discovery_response(prDev, info, wrqu, (char *)prP2PReq); - break; - - case P2P_CMD_ID_INVITATION_INDICATE: - { - status = mtk_p2p_wext_invitation_indicate(prDev, info, wrqu, (char *)(prP2PReq->aucBuffer)); - prP2PReq->outBufferLength = u4CmdLen; - if (copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - u4CmdLen + OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - else { - return 0; - } - break; - } - case P2P_CMD_ID_INVITATION_STATUS: - { - status = mtk_p2p_wext_invitation_status(prDev, info, wrqu, (char *)(prP2PReq->aucBuffer)); - prP2PReq->outBufferLength = u4CmdLen; - if (copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - u4CmdLen + OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - else { - return 0; - } - break; - } - case P2P_CMD_ID_GET_CH_LIST: - { - UINT_16 i; - UINT_8 NumOfChannel = 50; - RF_CHANNEL_INFO_T aucChannelList[50]; - UINT_8 ucMaxChannelNum = 50; - PUINT_8 pucChnlList = (PUINT_8)prP2PReq->aucBuffer; - - kalGetChnlList(prGlueInfo, BAND_NULL, ucMaxChannelNum, &NumOfChannel, aucChannelList); - if (NumOfChannel > 50) - NumOfChannel = 50; - prP2PReq->outBufferLength = NumOfChannel; - - for (i=0; i<NumOfChannel; i++) { -#if 0 - // 20120208 frog: modify to avoid clockwork warning. - prP2PReq->aucBuffer[i] = aucChannelList[i].ucChannelNum; -#else - *pucChnlList = aucChannelList[i].ucChannelNum; - pucChnlList++; -#endif - } - if(copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - NumOfChannel + OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - else { - return 0; - } - break; - } - - case P2P_CMD_ID_GET_OP_CH: - { - prP2PReq->inBufferLength = 4; - - status = wlanoidQueryP2pOpChannel(prGlueInfo->prAdapter, - prP2PReq->aucBuffer, - prP2PReq->inBufferLength, - &prP2PReq->outBufferLength); - - if (status == 0) { // WLAN_STATUS_SUCCESS - if (copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - prP2PReq->outBufferLength + OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - } - else { - if (copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - } - break; - } - - default: - status = -EOPNOTSUPP; - } - - break; -#if CFG_SUPPORT_ANTI_PIRACY - case PRIV_SEC_CHECK_OID: - if (u4CmdLen > sizeof(IW_P2P_TRANSPORT_STRUCT)) { - status = -EINVAL; - break; - } - if (copy_from_user(&(prGlueInfo->prP2PInfo->aucSecCheck[0]), - wrqu->data.pointer, - sizeof(IW_P2P_TRANSPORT_STRUCT))) { - printk(KERN_NOTICE "%s() copy_from_user oidBuf fail\n", __func__); - return -EFAULT; - } - - prP2PReq = (P_IW_P2P_TRANSPORT_STRUCT) (&(prGlueInfo->prP2PInfo->aucSecCheck[0])); - - switch(prP2PReq->u4CmdId) { - case P2P_CMD_ID_SEC_CHECK: - status = mtk_p2p_wext_get_sec_check_response(prDev, info, wrqu, (char *)prP2PReq); - break; - default: - status = -EOPNOTSUPP; - } - break; -#endif - case PRIV_CMD_P2P_VERSION: - if (u4CmdLen > sizeof(IW_P2P_TRANSPORT_STRUCT)) { - status = -EINVAL; - break; - } - - if (copy_from_user(&(prGlueInfo->prP2PInfo->aucOidBuf[0]), - wrqu->data.pointer, - sizeof(IW_P2P_TRANSPORT_STRUCT))) { - printk(KERN_NOTICE "%s() copy_from_user oidBuf fail\n", __func__); - return -EFAULT; - } - - prP2PReq = (P_IW_P2P_TRANSPORT_STRUCT) (&(prGlueInfo->prP2PInfo->aucOidBuf[0])); - - switch (prP2PReq->u4CmdId) { - case P2P_CMD_ID_P2P_VERSION: - status = mtk_p2p_wext_get_p2p_version(prDev, info, wrqu, (char *)prP2PReq); - break; - default: - status = -EOPNOTSUPP; - break; - } - - - /* Copy queried data to user. */ - if (status == 0) { // WLAN_STATUS_SUCCESS - if(copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - prP2PReq->outBufferLength + OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - } - - else { - if(copy_to_user(wrqu->data.pointer, - &(prGlueInfo->prP2PInfo->aucOidBuf[0]), - OFFSET_OF(IW_P2P_TRANSPORT_STRUCT, aucBuffer))) { - printk(KERN_NOTICE "%s() copy_to_user() fail\n", __func__); - return -EIO; - } - } - - break; - default: - return -EOPNOTSUPP; - } - - return status; + return 0; } |
