Skip to content
Commit 60f1626f authored by Anant Thazhemadam's avatar Anant Thazhemadam Committed by Jakub Kicinski
Browse files

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: b2a0f274 ("net: rtl8150: Use the new usb control message API.")
Signed-off-by: default avatarAnant Thazhemadam <anant.thazhemadam@gmail.com>
Link: https://lore.kernel.org/r/20201011173030.141582-1-anant.thazhemadam@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 71a0e29e
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment