Linux wireless drivers development
 help / color / mirror / Atom feed
From: Maya Erez <qca_merez@qca.qualcomm.com>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: Maya Erez <qca_merez@qca.qualcomm.com>,
	linux-wireless@vger.kernel.org, wil6210@qca.qualcomm.com
Subject: [PATCH 7/8] wil6210: prevent usage of incorrect TX hwtail
Date: Tue,  2 Aug 2016 14:42:11 +0300	[thread overview]
Message-ID: <1470138132-18071-8-git-send-email-qca_merez@qca.qualcomm.com> (raw)
In-Reply-To: <1470138132-18071-1-git-send-email-qca_merez@qca.qualcomm.com>

txdata->enabled is used in order to determine if the TX vring
is valid. As the data transmit is handled in a different context,
in case txdata->enabled is set before vring->hwtail is updated,
an old or corrupted vring->hwtail can be used.
Protect setting of txdata->enabled and vring->hwtail to prevent a
case where TX vring start handling TX packets before setting
vring->hwtail.

Signed-off-by: Maya Erez <qca_merez@qca.qualcomm.com>
---
 drivers/net/wireless/ath/wil6210/txrx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c
index f2f6a40..4c38520 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -873,9 +873,12 @@ int wil_vring_init_tx(struct wil6210_priv *wil, int id, int size,
 		rc = -EINVAL;
 		goto out_free;
 	}
-	vring->hwtail = le32_to_cpu(reply.cmd.tx_vring_tail_ptr);
 
+	spin_lock_bh(&txdata->lock);
+	vring->hwtail = le32_to_cpu(reply.cmd.tx_vring_tail_ptr);
 	txdata->enabled = 1;
+	spin_unlock_bh(&txdata->lock);
+
 	if (txdata->dot1x_open && (agg_wsize >= 0))
 		wil_addba_tx_request(wil, id, agg_wsize);
 
@@ -950,9 +953,11 @@ int wil_vring_init_bcast(struct wil6210_priv *wil, int id, int size)
 		rc = -EINVAL;
 		goto out_free;
 	}
-	vring->hwtail = le32_to_cpu(reply.cmd.tx_vring_tail_ptr);
 
+	spin_lock_bh(&txdata->lock);
+	vring->hwtail = le32_to_cpu(reply.cmd.tx_vring_tail_ptr);
 	txdata->enabled = 1;
+	spin_unlock_bh(&txdata->lock);
 
 	return 0;
  out_free:
-- 
1.9.1


  parent reply	other threads:[~2016-08-02 11:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 11:42 [PATCH 0/8] wil6210 pathches Maya Erez
2016-08-02 11:42 ` [PATCH 1/8] wil6210: align to latest auto generated wmi.h Maya Erez
2016-08-19 10:12   ` [1/8] " Kalle Valo
2016-08-02 11:42 ` [PATCH 2/8] wil6210: fix HALP handling in case of HALP vote time-out Maya Erez
2016-08-02 11:42 ` [PATCH 3/8] wil6210: support rx key setting for all TIDs Maya Erez
2016-08-02 11:42 ` [PATCH 4/8] wil6210: change HALP logging category to IRQ Maya Erez
2016-08-02 11:42 ` [PATCH 5/8] wil6210: fix stop p2p device handling Maya Erez
2016-08-02 11:42 ` [PATCH 6/8] wil6210: Fix driver down flow Maya Erez
2016-08-02 11:42 ` Maya Erez [this message]
2016-08-02 11:42 ` [PATCH 8/8] wil6210: fix wiphy registration sequence Maya Erez

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=1470138132-18071-8-git-send-email-qca_merez@qca.qualcomm.com \
    --to=qca_merez@qca.qualcomm.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=wil6210@qca.qualcomm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox