Commit eba57168 authored by Shayne Chen's avatar Shayne Chen Committed by Felix Fietkau

mt76: fix possible undetected invalid MAC address

Make sure the MAC address is checked before function returns.

If CONFIG_OF is set and the device node is null, the function will
return directly, and an invalid MAC address will not be checked.
Signed-off-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 37a68e00
...@@ -80,13 +80,14 @@ mt76_eeprom_override(struct mt76_dev *dev) ...@@ -80,13 +80,14 @@ mt76_eeprom_override(struct mt76_dev *dev)
const u8 *mac; const u8 *mac;
if (!np) if (!np)
return; goto out;
mac = of_get_mac_address(np); mac = of_get_mac_address(np);
if (!IS_ERR(mac)) if (!IS_ERR(mac))
ether_addr_copy(dev->macaddr, mac); ether_addr_copy(dev->macaddr, mac);
#endif #endif
out:
if (!is_valid_ether_addr(dev->macaddr)) { if (!is_valid_ether_addr(dev->macaddr)) {
eth_random_addr(dev->macaddr); eth_random_addr(dev->macaddr);
dev_info(dev->dev, dev_info(dev->dev,
......
Markdown is supported
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