forked from Minki/linux
staging: r8188eu: replace rtw_malloc/copy_from_user sequence with memdup_user
memdup_user is shorter and expressively. Signed-off-by: Ivan Safonov <insafonov@gmail.com> Link: https://lore.kernel.org/r/20200412173716.846469-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
823b6a951f
commit
9ed05c15a3
@ -2012,14 +2012,9 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
|
|||||||
if (!p->pointer || p->length != sizeof(struct ieee_param))
|
if (!p->pointer || p->length != sizeof(struct ieee_param))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
param = (struct ieee_param *)rtw_malloc(p->length);
|
param = memdup_user(p->pointer, p->length);
|
||||||
if (!param)
|
if (IS_ERR(param))
|
||||||
return -ENOMEM;
|
return PTR_ERR(param);
|
||||||
|
|
||||||
if (copy_from_user(param, p->pointer, p->length)) {
|
|
||||||
kfree(param);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (param->cmd) {
|
switch (param->cmd) {
|
||||||
case IEEE_CMD_SET_WPA_PARAM:
|
case IEEE_CMD_SET_WPA_PARAM:
|
||||||
@ -2789,14 +2784,9 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
|
|||||||
if (!p->pointer || p->length != sizeof(struct ieee_param))
|
if (!p->pointer || p->length != sizeof(struct ieee_param))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
param = (struct ieee_param *)rtw_malloc(p->length);
|
param = memdup_user(p->pointer, p->length);
|
||||||
if (!param)
|
if (IS_ERR(param))
|
||||||
return -ENOMEM;
|
return PTR_ERR(param);
|
||||||
|
|
||||||
if (copy_from_user(param, p->pointer, p->length)) {
|
|
||||||
kfree(param);
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (param->cmd) {
|
switch (param->cmd) {
|
||||||
case RTL871X_HOSTAPD_FLUSH:
|
case RTL871X_HOSTAPD_FLUSH:
|
||||||
|
Loading…
Reference in New Issue
Block a user