Re: [ath5k-devel] [PATCH 2/2] ath5k: don't change mac in eeprom_read_mac on error

From: Nick Kossifidis
Date: Sat Mar 07 2009 - 07:06:21 EST


2009/3/7 Jiri Slaby <jirislaby@xxxxxxxxx>:
> 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@xxxxxxxxx>
> Cc: Nick Kossifidis <jirislaby@xxxxxxxxx>
> Cc: Luis R. Rodriguez <lrodriguez@xxxxxxxxxxx>
> Cc: Bob Copeland <me@xxxxxxxxxxxxxxx>
> ---
> Âdrivers/net/wireless/ath5k/eeprom.c | Â Â9 +++------
> Â1 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/ath5k/eeprom.c b/drivers/net/wireless/ath5k/eeprom.c
> index a54ee7e..ac45ca4 100644
> --- a/drivers/net/wireless/ath5k/eeprom.c
> +++ b/drivers/net/wireless/ath5k/eeprom.c
> @@ -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;
> @@ -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;
> Â}
>

Acked-by: Nick Kossifidis <mickflemm@xxxxxxxxx>


--
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/