From: Viorel Suman Date: Sun, 1 Mar 2015 23:01:27 +0200 Subject: [ath9k-devel] [PATCH] ath9k: guard "ah->intr_ref_cnt" from going "negative" Message-ID: <1425243687-3001-1-git-send-email-viorel.suman@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org The counter "ah->intr_ref_cnt" goes into "negative" territory from "ath9k_stop" method by calling "disable_interrupts" method directly, and then - indirectly by calling "ath_prepare_reset" method. The patch guards the counter from going into a "negative" territory. Signed-off-by: Viorel Suman --- drivers/net/wireless/ath/ath9k/mac.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index bba85d1..9369133 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -796,11 +796,24 @@ EXPORT_SYMBOL(ath9k_hw_kill_interrupts); void ath9k_hw_disable_interrupts(struct ath_hw *ah) { - if (!(ah->imask & ATH9K_INT_GLOBAL)) - atomic_set(&ah->intr_ref_cnt, -1); - else - atomic_dec(&ah->intr_ref_cnt); - + struct ath_common *common = ath9k_hw_common(ah); + int rcount; + + if (ah->imask & ATH9K_INT_GLOBAL) { + rcount = atomic_read(&ah->intr_ref_cnt); + if (rcount < 0) { + ath_dbg(common, INTERRUPT, + "IER already disabled ref count %d\n", rcount); + return; + } + if (rcount > 0 && !atomic_dec_and_test(&ah->intr_ref_cnt)) { + ath_dbg(common, INTERRUPT, + "Do not disable IER ref count %d\n", + atomic_read(&ah->intr_ref_cnt)); + return; + } + } + atomic_set(&ah->intr_ref_cnt, -1); ath9k_hw_kill_interrupts(ah); } EXPORT_SYMBOL(ath9k_hw_disable_interrupts); -- 2.3.0