wil6210: use memdup_user
authorGeliang Tang <geliangtang@gmail.com>
Sat, 6 May 2017 15:42:19 +0000 (23:42 +0800)
committerKalle Valo <kvalo@qca.qualcomm.com>
Fri, 19 May 2017 07:53:06 +0000 (10:53 +0300)
Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/wil6210/debugfs.c

index 5648ebbd0e1663720c2fd398d7e29fc623f9832b..5b0f9fc66bb60a85e285f54a30f24b8a502813ad 100644 (file)
@@ -795,15 +795,11 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
        struct wireless_dev *wdev = wil_to_wdev(wil);
        struct cfg80211_mgmt_tx_params params;
        int rc;
-       void *frame = kmalloc(len, GFP_KERNEL);
+       void *frame;
 
-       if (!frame)
-               return -ENOMEM;
-
-       if (copy_from_user(frame, buf, len)) {
-               kfree(frame);
-               return -EIO;
-       }
+       frame = memdup_user(buf, len);
+       if (IS_ERR(frame))
+               return PTR_ERR(frame);
 
        params.buf = frame;
        params.len = len;