Return-path: Received: from smtp.wellnetcz.com ([212.24.148.102]:55085 "EHLO smtp.wellnetcz.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072AbZCGJ1h (ORCPT ); Sat, 7 Mar 2009 04:27:37 -0500 From: Jiri Slaby To: "John W. Linville" Cc: linux-wireless@vger.kernel.org, ath5k-devel@venema.h4ckr.net, linux-kernel@vger.kernel.org, Jiri Slaby , "Luis R. Rodriguez" , Bob Copeland Subject: [PATCH 2/2] ath5k: don't change mac in eeprom_read_mac on error Date: Sat, 7 Mar 2009 10:26:42 +0100 Message-Id: <1236418002-2189-2-git-send-email-jirislaby@gmail.com> (sfid-20090307_102759_090306_8B88B481) In-Reply-To: <1236418002-2189-1-git-send-email-jirislaby@gmail.com> References: <1236418002-2189-1-git-send-email-jirislaby@gmail.com> Sender: linux-wireless-owner@vger.kernel.org List-ID: 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 Cc: Nick Kossifidis Cc: Luis R. Rodriguez Cc: Bob Copeland --- 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; } -- 1.6.1.3