diff options
author | Ivan Safonov <insafonov@gmail.com> | 2020-04-12 20:37:16 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-13 14:57:51 +0200 |
commit | 9ed05c15a319e9758da56c3d034a6b50eb9fa2de (patch) | |
tree | 1d3eca64e87c34fc8fdc1482c9fa2ab45bad878c /drivers/staging/rtl8188eu | |
parent | 823b6a951fa28cec07771a43929436ae5961ed83 (diff) |
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>
Diffstat (limited to 'drivers/staging/rtl8188eu')
-rw-r--r-- | drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 0aff01bb69c3..d5968ef9f43d 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -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)) return -EINVAL; - param = (struct ieee_param *)rtw_malloc(p->length); - if (!param) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - return -EFAULT; - } + param = memdup_user(p->pointer, p->length); + if (IS_ERR(param)) + return PTR_ERR(param); switch (param->cmd) { 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)) return -EINVAL; - param = (struct ieee_param *)rtw_malloc(p->length); - if (!param) - return -ENOMEM; - - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - return -EFAULT; - } + param = memdup_user(p->pointer, p->length); + if (IS_ERR(param)) + return PTR_ERR(param); switch (param->cmd) { case RTL871X_HOSTAPD_FLUSH: |