]> git.baikalelectronics.ru Git - kernel.git/commit
net: usb: rtl8150: don't incorrectly assign random MAC addresses
authorAnant Thazhemadam <anant.thazhemadam@gmail.com>
Sun, 11 Oct 2020 17:30:30 +0000 (23:00 +0530)
committerJakub Kicinski <kuba@kernel.org>
Sun, 18 Oct 2020 19:57:30 +0000 (12:57 -0700)
commitd3464f749e0569d1ff62ce71641fa85ccb9d2c89
tree23cddf68a1ca7cc7d46ef51f572fc3e2696fb2be
parent3f35b809e3618df38cd972b2fc5a43c18fabcfd9
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: 7f5c31597203 ("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>
drivers/net/usb/rtl8150.c