Skip to contentSkip to conversation

iommu/amd: Fix bug in put_pasid_state_wait

PATCH In review Oded Gabbay 2 participants 3 messages Apr 16, 2015 – May 4, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: Fix bug in put_pasid_state_wait

This patch fixes a bug in put_pasid_state_wait that appeared in kernel 4.0 The bug is that pasid_state->count wasn't decremented before entering the wait_event. Thus, the condition in wait_event will never be true.

The fix is to decrement (atomically) the pasid_state->count before the wait_event.

---
 drivers/iommu/amd_iommu_v2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iommu/amd_iommu_v2.c +1 -0
index 6d5a5c4..173e70d 100644
@@ -266,6 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
 static void put_pasid_state_wait(struct pasid_state *pasid_state)
 {
+	atomic_dec(&pasid_state->count);
 	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
 	free_pasid_state(pasid_state);
 }
Signature · 1 line
1.9.1
#1 lore raw

Hi Joerg,
Could you please take a look at this patch ?
I want it to be included in stable asap so Fedora 22 will pick it up.

Thanks,
Oded

Quoted 26 lines · Oded Gabbay

This patch fixes a bug in put_pasid_state_wait that appeared in kernel 4.0 The bug is that pasid_state->count wasn't decremented before entering the wait_event. Thus, the condition in wait_event will never be true.

The fix is to decrement (atomically) the pasid_state->count before the wait_event.

---
  drivers/iommu/amd_iommu_v2.c | 1 +
  1 file changed, 1 insertion(+)
drivers/iommu/amd_iommu_v2.c +1 -0
index 6d5a5c4..173e70d 100644
@@ -266,6 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state)
 
  static void put_pasid_state_wait(struct pasid_state *pasid_state)
  {
+	atomic_dec(&pasid_state->count);
  	wait_event(pasid_state->wq, !atomic_read(&pasid_state->count));
  	free_pasid_state(pasid_state);
  }
maintainer
#2 lore raw
In reply to Oded Gabbay
Quoted 6 lines · Oded Gabbay

This patch fixes a bug in put_pasid_state_wait that appeared in kernel 4.0 The bug is that pasid_state->count wasn't decremented before entering the wait_event. Thus, the condition in wait_event will never be true.

The fix is to decrement (atomically) the pasid_state->count before the wait_event.

Gah! This issue was already pointed out in the original review of the patch, looks like I applied the wrong version. Thanks for the fix, I applied it to iommu/fixes.

Joerg