From: Jiri Slaby <jirislaby@gmail.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, ath5k-devel@venema.h4ckr.net,
linux-kernel@vger.kernel.org, Jiri Slaby <jirislaby@gmail.com>,
"Luis R. Rodriguez" <lrodriguez@atheros.com>,
Bob Copeland <me@bobcopeland.com>
Subject: [PATCH 2/2] ath5k: don't change mac in eeprom_read_mac on error
Date: Sat, 7 Mar 2009 10:26:42 +0100 [thread overview]
Message-ID: <1236418002-2189-2-git-send-email-jirislaby@gmail.com> (raw)
In-Reply-To: <1236418002-2189-1-git-send-email-jirislaby@gmail.com>
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>
Cc: Nick Kossifidis <jirislaby@gmail.com>
Cc: Luis R. Rodriguez <lrodriguez@atheros.com>
Cc: Bob Copeland <me@bobcopeland.com>
---
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
next prev parent reply other threads:[~2009-03-07 9:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 9:26 [PATCH 1/2] ath5k: constify stuff Jiri Slaby
2009-03-07 9:26 ` Jiri Slaby [this message]
2009-03-07 12:06 ` [ath5k-devel] [PATCH 2/2] ath5k: don't change mac in eeprom_read_mac on error Nick Kossifidis
2009-03-07 12:06 ` Nick Kossifidis
2009-03-07 12:34 ` Bob Copeland
2009-03-07 12:03 ` [PATCH 1/2] ath5k: constify stuff Nick Kossifidis
2009-03-07 12:03 ` Nick Kossifidis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1236418002-2189-2-git-send-email-jirislaby@gmail.com \
--to=jirislaby@gmail.com \
--cc=ath5k-devel@venema.h4ckr.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=lrodriguez@atheros.com \
--cc=me@bobcopeland.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.