summaryrefslogtreecommitdiff
path: root/drivers/net/usb/rtl8150.c
diff options
context:
space:
mode:
authorAnant Thazhemadam <anant.thazhemadam@gmail.com>2020-10-11 23:00:30 +0530
committerJakub Kicinski <kuba@kernel.org>2020-10-18 12:57:30 -0700
commit60f1626f0f866809de801724c3d180a9f322841e (patch)
tree23cddf68a1ca7cc7d46ef51f572fc3e2696fb2be /drivers/net/usb/rtl8150.c
parent71a0e29e99405d89b695882d52eec60844173697 (diff)
net: usb: rtl8150: don't incorrectly assign random MAC addresses
In set_ethernet_addr(), if get_registers() succeeds, the ethernet address that was read must be copied over. Otherwise, a random ethernet address must be assigned. get_registers() returns 0 if successful, and negative error number otherwise. However, in set_ethernet_addr(), this return value is incorrectly checked. Since this return value will never be equal to sizeof(node_id), a random MAC address will always be generated and assigned to the device; even in cases when get_registers() is successful. Correctly modifying the condition that checks if get_registers() was successful or not fixes this problem, and copies the ethernet address appropriately. Fixes: b2a0f274e3f7 ("net: rtl8150: Use the new usb control message API.") Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com> Link: https://lore.kernel.org/r/20201011173030.141582-1-anant.thazhemadam@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/usb/rtl8150.c')
-rw-r--r--drivers/net/usb/rtl8150.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index f020401adf04..bf8a60533f3e 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -261,7 +261,7 @@ static void set_ethernet_addr(rtl8150_t *dev)
ret = get_registers(dev, IDR, sizeof(node_id), node_id);
- if (ret == sizeof(node_id)) {
+ if (!ret) {
ether_addr_copy(dev->netdev->dev_addr, node_id);
} else {
eth_hw_addr_random(dev->netdev);