rtl8188eu: Add checks for p->length and remove some goto statements

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
This commit is contained in:
Larry Finger 2020-02-10 09:21:53 -06:00
parent b572d3030a
commit f86165a975

View file

@ -6720,21 +6720,16 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
/* down(&ieee->wx_sem); */ /* down(&ieee->wx_sem); */
if (p->length < sizeof(struct ieee_param) || !p->pointer) { if (!p->pointer || p->length != sizeof(struct ieee_param))
ret = -EINVAL; return -EINVAL;
goto out;
}
param = (struct ieee_param *)rtw_malloc(p->length); param = (struct ieee_param *)rtw_malloc(p->length);
if (param == NULL) { if (param == NULL)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
if (copy_from_user(param, p->pointer, p->length)) { if (copy_from_user(param, p->pointer, p->length)) {
rtw_mfree((u8 *)param, p->length); rtw_mfree((u8 *)param, p->length);
ret = -EFAULT; return -EFAULT;
goto out;
} }
switch (param->cmd) { switch (param->cmd) {
@ -6767,13 +6762,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
ret = -EFAULT; ret = -EFAULT;
rtw_mfree((u8 *)param, p->length); rtw_mfree((u8 *)param, p->length);
out:
/* up(&ieee->wx_sem); */
return ret; return ret;
} }
#ifdef CONFIG_AP_MODE #ifdef CONFIG_AP_MODE
@ -7574,32 +7563,21 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
* so, we just check hw_init_completed * so, we just check hw_init_completed
*/ */
if (!rtw_is_hw_init_completed(padapter)) { if (!rtw_is_hw_init_completed(padapter))
ret = -EPERM; return -EPERM;
goto out;
}
if (!p->pointer || p->length != sizeof(struct ieee_param))
/* if (p->length < sizeof(struct ieee_param) || !p->pointer){ */ return -EINVAL;
if (!p->pointer) {
ret = -EINVAL;
goto out;
}
param = (struct ieee_param *)rtw_malloc(p->length); param = (struct ieee_param *)rtw_malloc(p->length);
if (param == NULL) { if (param == NULL)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
if (copy_from_user(param, p->pointer, p->length)) { if (copy_from_user(param, p->pointer, p->length)) {
rtw_mfree((u8 *)param, p->length); rtw_mfree((u8 *)param, p->length);
ret = -EFAULT; return -EFAULT;
goto out;
} }
/* RTW_INFO("%s, cmd=%d\n", __func__, param->cmd); */
switch (param->cmd) { switch (param->cmd) {
case RTL871X_HOSTAPD_FLUSH: case RTL871X_HOSTAPD_FLUSH:
@ -7692,10 +7670,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
rtw_mfree((u8 *)param, p->length); rtw_mfree((u8 *)param, p->length);
out:
return ret; return ret;
} }
#endif #endif