Commit bc4bf94c authored by Ivan Safonov's avatar Ivan Safonov Committed by Greg Kroah-Hartman
Browse files

staging:wlan-ng: use memdup_user instead of kmalloc/copy_from_user



memdup_user() is shorter and safer equivalent
of kmalloc/copy_from_user pair.

Signed-off-by: default avatarIvan Safonov <insafonov@gmail.com>
Link: https://lore.kernel.org/r/20210213120527.451531-1-insafonov@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b2591ab0
Loading
Loading
Loading
Loading
+13 −15
Original line number Diff line number Diff line
@@ -569,12 +569,12 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
		goto bail;
	}

	/* Allocate a buf of size req->len */
	msgbuf = kmalloc(req->len, GFP_KERNEL);
	if (msgbuf) {
		if (copy_from_user(msgbuf, (void __user *)req->data, req->len))
			result = -EFAULT;
		else
	msgbuf = memdup_user(req->data, req->len);
	if (IS_ERR(msgbuf)) {
		result = PTR_ERR(msgbuf);
		goto bail;
	}

	result = p80211req_dorequest(wlandev, msgbuf);

	if (result == 0) {
@@ -584,9 +584,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev,
		}
	}
	kfree(msgbuf);
	} else {
		result = -ENOMEM;
	}

bail:
	/* If allocate,copyfrom or copyto fails, return errno */
	return result;