Skip to contentSkip to conversation

ath10k: Fix crash due to tasklet race.

PATCH In review [email protected] 3 participants 6 messages Oct 29, 2013 – Nov 6, 2013 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath10k: Fix crash due to tasklet race.

From: Ben Greear <[email protected]>

The tasklet can run after the rings have been cleaned up, so check for NULL before de-referencing the ring.

---
 drivers/net/wireless/ath/ath10k/ce.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +8 -2
index d243f28..dfcfda9 100644
@@ -547,12 +547,18 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
 	struct ath10k_ce_ring *src_ring = ce_state->src_ring;
 	u32 ctrl_addr = ce_state->ctrl_addr;
 	struct ath10k *ar = ce_state->ar;
-	unsigned int nentries_mask = src_ring->nentries_mask;
-	unsigned int sw_index = src_ring->sw_index;
+	unsigned int nentries_mask;
+	unsigned int sw_index;
 	struct ce_desc *sdesc, *sbase;
 	unsigned int read_index;
 	int ret;
 
+	if (!src_ring)
+		return -EIO;
+
+	nentries_mask = src_ring->nentries_mask;
+	sw_index = src_ring->sw_index;
+
 	if (src_ring->hw_index == sw_index) {
 		/*
 		 * The SW completion index has caught up with the cached
Signature · 7 lines
1.7.11.7


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#1 lore raw
Quoted 25 lines · On 29 October 2013 22:38, <[email protected]> wrote:

From: Ben Greear <[email protected]>

The tasklet can run after the rings have been cleaned up, so check for NULL before de-referencing the ring.

---
 drivers/net/wireless/ath/ath10k/ce.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +2 -2
index d243f28..dfcfda9 100644
@@ -547,12 +547,18 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
        struct ath10k_ce_ring *src_ring = ce_state->src_ring;
        u32 ctrl_addr = ce_state->ctrl_addr;
        struct ath10k *ar = ce_state->ar;
-       unsigned int nentries_mask = src_ring->nentries_mask;
-       unsigned int sw_index = src_ring->sw_index;
+       unsigned int nentries_mask;
+       unsigned int sw_index;
        struct ce_desc *sdesc, *sbase;
        unsigned int read_index;
        int ret;

drivers/net/wireless/ath/ath10k/ce.c static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state, · line 564

Quoted 10 lines
drivers/net/wireless/ath/ath10k/ce.c +6 -0
 
+       if (!src_ring)
+               return -EIO;
+
+       nentries_mask = src_ring->nentries_mask;
+       sw_index = src_ring->sw_index;
+
        if (src_ring->hw_index == sw_index) {
                /*
                 * The SW completion index has caught up with the cached

I don't think this is a proper way to fix the problem. What should be done is initialization clean up and some reordering to prevent this from happening in the first place.

Michał

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#2 lore raw
Quoted 27 lines · Michal Kazior
Quoted 26 lines · On 29 October 2013 22:38, <[email protected]> wrote:

From: Ben Greear <[email protected]>

The tasklet can run after the rings have been cleaned up, so check for NULL before de-referencing the ring.

---
 drivers/net/wireless/ath/ath10k/ce.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +2 -2
index d243f28..dfcfda9 100644
@@ -547,12 +547,18 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
        struct ath10k_ce_ring *src_ring = ce_state->src_ring;
        u32 ctrl_addr = ce_state->ctrl_addr;
        struct ath10k *ar = ce_state->ar;
-       unsigned int nentries_mask = src_ring->nentries_mask;
-       unsigned int sw_index = src_ring->sw_index;
+       unsigned int nentries_mask;
+       unsigned int sw_index;
        struct ce_desc *sdesc, *sbase;
        unsigned int read_index;
        int ret;
 
Quoted 6 lines

drivers/net/wireless/ath/ath10k/ce.c static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state, · line 557

Quoted 2 lines
drivers/net/wireless/ath/ath10k/ce.c +2 -0
+       if (!src_ring)
+               return -EIO;

I don't think this is a proper way to fix the problem. What should be done is initialization clean up and some reordering to prevent this from happening in the first place.

I agree with Michal, but as we don't have any better fix for this issue I'm inclined to take the patch anyway. Maybe there just should be a comment stating that it's an ugly workaround and a WARN_ON() to make sure that we properly fix the interrupt initialisation.

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#3 lore raw
Quoted 36 lines · Kalle Valo
Quoted 27 lines · Michal Kazior
Quoted 26 lines · On 29 October 2013 22:38, <[email protected]> wrote:

From: Ben Greear <[email protected]>

The tasklet can run after the rings have been cleaned up, so check for NULL before de-referencing the ring.

---
 drivers/net/wireless/ath/ath10k/ce.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +2 -2
index d243f28..dfcfda9 100644
@@ -547,12 +547,18 @@ static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state,
        struct ath10k_ce_ring *src_ring = ce_state->src_ring;
        u32 ctrl_addr = ce_state->ctrl_addr;
        struct ath10k *ar = ce_state->ar;
-       unsigned int nentries_mask = src_ring->nentries_mask;
-       unsigned int sw_index = src_ring->sw_index;
+       unsigned int nentries_mask;
+       unsigned int sw_index;
        struct ce_desc *sdesc, *sbase;
        unsigned int read_index;
        int ret;
 
Quoted 6 lines

drivers/net/wireless/ath/ath10k/ce.c static int ath10k_ce_completed_send_next_nolock(struct ath10k_ce_pipe *ce_state, · line 557

Quoted 2 lines
drivers/net/wireless/ath/ath10k/ce.c +2 -0
+       if (!src_ring)
+               return -EIO;

I don't think this is a proper way to fix the problem. What should be done is initialization clean up and some reordering to prevent this from happening in the first place.

Quoted 4 lines

I agree with Michal, but as we don't have any better fix for this issue I'm inclined to take the patch anyway. Maybe there just should be a comment stating that it's an ugly workaround and a WARN_ON() to make sure that we properly fix the interrupt initialisation.

This issue alone should actually be fixed in my pci fixes RFT.

Michał

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k

#4 lore raw
In reply to [email protected]
Quoted 6 lines · [email protected] writes:

From: Ben Greear <[email protected]>

The tasklet can run after the rings have been cleaned up, so check for NULL before de-referencing the ring.

I'll drop this as Michal's patch has a proper fix for this issue.

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
author
#5 lore raw
Quoted 10 lines · Kalle Valo
Quoted 6 lines · [email protected] writes:

From: Ben Greear <[email protected]>

The tasklet can run after the rings have been cleaned up, so check for NULL before de-referencing the ring.

I'll drop this as Michal's patch has a proper fix for this issue.

Ok, that sounds fine. I'll rebase when you push his patches and drop my patch for continued testing.

Thanks,
Ben

Signature · 8 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k