Skip to content

Commit

Permalink
ath5k: don't change mac in eeprom_read_mac on error
Browse files Browse the repository at this point in the history
Do not touch mac parameter passed to ath5k_eeprom_read_mac unless
we are sure we have correct address. I.e. when returning error, do
not change it.

While at it, use '= {}' compiler trick for memsetting mac_d.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Acked-by: Nick Kossifidis <mickflemm@gmail.com>
Cc: Luis R. Rodriguez <lrodriguez@atheros.com>
Acked-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Jiri Slaby authored and John W. Linville committed Mar 16, 2009
1 parent 2c91108 commit 8d6c39e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/net/wireless/ath5k/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,14 +1418,11 @@ ath5k_eeprom_init(struct ath5k_hw *ah)
*/
int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
{
u8 mac_d[ETH_ALEN];
u8 mac_d[ETH_ALEN] = {};
u32 total, offset;
u16 data;
int octet, ret;

memset(mac, 0, ETH_ALEN);
memset(mac_d, 0, ETH_ALEN);

ret = ath5k_hw_eeprom_read(ah, 0x20, &data);
if (ret)
return ret;
Expand All @@ -1441,11 +1438,11 @@ int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
octet += 2;
}

memcpy(mac, mac_d, ETH_ALEN);

if (!total || total == 3 * 0xffff)
return -EINVAL;

memcpy(mac, mac_d, ETH_ALEN);

return 0;
}

Expand Down

0 comments on commit 8d6c39e

Please sign in to comment.