From: Bob Copeland <me@bobcopeland.com>
To: Steven Rostedt <rostedt@goodmis.org>, linville@tuxdriver.com
Cc: Nick Kossifidis <mickflemm@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
jirislaby@gmail.com, lrodriguez@atheros.com,
linux-wireless@vger.kernel.org, ath5k-devel@lists.ath5k.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] ath5k: avoid and warn on potential infinite loop
Date: Tue, 19 May 2009 23:37:31 -0400 [thread overview]
Message-ID: <20090520033731.GA16640@hash.localnet> (raw)
In-Reply-To: <alpine.DEB.2.00.0905190751200.1767@gandalf.stny.rr.com>
If we are trying to interpolate a curve with slope == 0, the return
value will always be the y-coordinate. In this code we are looping
until we reach a minimum y-coordinate on a line, which in the 0-slope
case can never happen, thus the loop never terminates.
The PCDAC steps come from the EEPROM and should never be equal, but
we should gracefully handle that case, so warn and bail out.
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
This ok? (based on top of the wireless-testing tree -- the patch
that's already there can go for 2.6.30. This is in addition to that
patch, this handles the other, unlikely, corner case.)
Having looked at the code, I don't see why we need to loop at all,
couldn't we just invert the slope and solve directly for y=0?
Certainly recomputing the slope in a loop could be optimized.
Anyway, that's another patch for another day.
drivers/net/wireless/ath/ath5k/phy.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index d0d1c35..a876ca8 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -1897,6 +1897,9 @@ ath5k_get_linear_pcdac_min(const u8 *stepL, const u8 *stepR,
s16 min_pwrL, min_pwrR;
s16 pwr_i;
+ if (WARN_ON(stepL[0] == stepL[1] || stepR[0] == stepR[1]))
+ return 0;
+
if (pwrL[0] == pwrL[1])
min_pwrL = pwrL[0];
else {
--
1.6.0.6
--
Bob Copeland %% www.bobcopeland.com
prev parent reply other threads:[~2009-05-20 3:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-19 0:28 [PATCH] ath5k: prevent infinite loop Steven Rostedt
2009-05-19 0:34 ` Nick Kossifidis
2009-05-19 0:43 ` Steven Rostedt
2009-05-19 6:32 ` Nick Kossifidis
2009-05-19 6:39 ` [ath5k-devel] " Luis R. Rodriguez
2009-05-19 11:45 ` Steven Rostedt
2009-05-19 16:38 ` Luis R. Rodriguez
2009-05-19 11:42 ` Bob Copeland
2009-05-19 11:54 ` Steven Rostedt
2009-05-19 12:34 ` Bob Copeland
2009-05-20 3:37 ` Bob Copeland [this message]
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=20090520033731.GA16640@hash.localnet \
--to=me@bobcopeland.com \
--cc=akpm@linux-foundation.org \
--cc=ath5k-devel@lists.ath5k.org \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=lrodriguez@atheros.com \
--cc=mickflemm@gmail.com \
--cc=rostedt@goodmis.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).