[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171219191412.14880-4-andriy.shevchenko@linux.intel.com>
Date: Tue, 19 Dec 2017 21:14:12 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
Larry Finger <Larry.Finger@...inger.net>,
Florian Schilhabel <florian.c.schilhabel@...glemail.com>,
devel@...verdev.osuosl.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 4/4] staging: rtl8712: Replace mac address parsing
Replace copy_from_user() + mac_pton() with mac_pton_from_user().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index e30a5be5f318..3f82c39eb071 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -1953,7 +1953,7 @@ static int r871x_get_ap_info(struct net_device *dev,
struct list_head *plist, *phead;
unsigned char *pbuf;
u8 bssid[ETH_ALEN];
- char data[33];
+ int ret;
if (padapter->bDriverStopped || (pdata == NULL))
return -EINVAL;
@@ -1967,9 +1967,11 @@ static int r871x_get_ap_info(struct net_device *dev,
pdata->flags = 0;
if (pdata->length < 32)
return -EINVAL;
- if (copy_from_user(data, pdata->pointer, 32))
- return -EINVAL;
- data[32] = 0;
+ ret = mac_pton_from_user(pdata->pointer, 32, bssid);
+ if (ret)
+ return ret;
+
+ netdev_info(dev, "r8712u: BSSID:%pM\n", bssid);
spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL);
phead = &queue->queue;
@@ -1978,14 +1980,6 @@ static int r871x_get_ap_info(struct net_device *dev,
if (end_of_queue_search(phead, plist))
break;
pnetwork = container_of(plist, struct wlan_network, list);
- if (!mac_pton(data, bssid)) {
- netdev_info(dev, "r8712u: Invalid BSSID '%s'.\n",
- (u8 *)data);
- spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock),
- irqL);
- return -EINVAL;
- }
- netdev_info(dev, "r8712u: BSSID:%pM\n", bssid);
if (ether_addr_equal(bssid, pnetwork->network.MacAddress)) {
/* BSSID match, then check if supporting wpa/wpa2 */
pbuf = r8712_get_wpa_ie(&pnetwork->network.IEs[12],
--
2.15.1
Powered by blists - more mailing lists