Skip to contentSkip to conversation

plic: Fix lock/unlock mismatch in plic__irq_trig()

PATCH Applied jk.hong 2 participants 2 messages Apr 14 – May 18

Subsystems (2)
lore
Share & tools
lore

jk.hong

author
#0 lore raw

PATCH 1/1 plic: Fix lock/unlock mismatch in plic__irq_trig()

plic__irq_trig() may call mutex_unlock(&s->irq_lock) without having acquired the lock first. In some condition, the function jumps to the done label and s->irq_lock is unlocked without lock first.

---
 riscv/plic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
riscv/plic.c +1 -2
index 6bd13ac..a622005 100644
@@ -217,7 +217,7 @@ static void plic__irq_trig(struct kvm *kvm, int irq, int level, bool edge)
 		return;
 
 	if (irq <= 0 || s->num_irq <= (u32)irq)
-		goto done;
+		return;
 
 	mutex_lock(&s->irq_lock);
 
@@ -261,7 +261,6 @@ static void plic__irq_trig(struct kvm *kvm, int irq, int level, bool edge)
 			break;
 	}
 
-done:
 	mutex_unlock(&s->irq_lock);
 }
 
Signature · 1 line
2.48.1
Applied
#1 lore raw
Quoted 4 lines · jk.hong

plic__irq_trig() may call mutex_unlock(&s->irq_lock) without having acquired the lock first. In some condition, the function jumps to the done label and s->irq_lock is unlocked without lock first.

Applied to kvmtool (master), thanks!

[1/1] plic: Fix lock/unlock mismatch in plic__irq_trig()

      https://git.kernel.org/will/kvmtool/c/5a1233d80dec

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev