[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171219191412.14880-3-andriy.shevchenko@linux.intel.com>
Date: Tue, 19 Dec 2017 21:14:11 +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 3/4] staging: rtl8723bs: Replace mac address parsing
Replace copy_from_user() + sscanf() with mac_pton_from_user().
While here, replace memcpy(..., ETH_ALEN) with ether_addr_copy().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
drivers/staging/rtl8723bs/core/rtw_debug.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c
index b5dd244fee8f..79ac91a6c3ba 100644
--- a/drivers/staging/rtl8723bs/core/rtw_debug.c
+++ b/drivers/staging/rtl8723bs/core/rtw_debug.c
@@ -380,21 +380,15 @@ ssize_t proc_set_roam_tgt_addr(struct file *file, const char __user *buffer, siz
{
struct net_device *dev = data;
struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
-
- char tmp[32];
u8 addr[ETH_ALEN];
+ int ret;
- if (count < 1)
- return -EFAULT;
-
- if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) {
-
- int num = sscanf(tmp, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", addr, addr+1, addr+2, addr+3, addr+4, addr+5);
- if (num == 6)
- memcpy(adapter->mlmepriv.roam_tgt_addr, addr, ETH_ALEN);
+ ret = mac_pton_from_user(buffer, count, addr);
+ if (ret)
+ return ret;
- DBG_871X("set roam_tgt_addr to "MAC_FMT"\n", MAC_ARG(adapter->mlmepriv.roam_tgt_addr));
- }
+ ether_addr_copy(adapter->mlmepriv.roam_tgt_addr, addr);
+ DBG_871X("set roam_tgt_addr to "MAC_FMT"\n", MAC_ARG(adapter->mlmepriv.roam_tgt_addr));
return count;
}
--
2.15.1
Powered by blists - more mailing lists