Browse Source

kvm: irqchip: fix memory leak

We were taking the exit path after checking ue->flags and return value
of setup_routing_entry(), but 'e' was not freed incase of a failure.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Sudip Mukherjee 10 years ago
parent
commit
ba60c41ae3
1 changed files with 6 additions and 2 deletions
  1. 6 2
      virt/kvm/irqchip.c

+ 6 - 2
virt/kvm/irqchip.c

@@ -213,11 +213,15 @@ int kvm_set_irq_routing(struct kvm *kvm,
 			goto out;
 			goto out;
 
 
 		r = -EINVAL;
 		r = -EINVAL;
-		if (ue->flags)
+		if (ue->flags) {
+			kfree(e);
 			goto out;
 			goto out;
+		}
 		r = setup_routing_entry(new, e, ue);
 		r = setup_routing_entry(new, e, ue);
-		if (r)
+		if (r) {
+			kfree(e);
 			goto out;
 			goto out;
+		}
 		++ue;
 		++ue;
 	}
 	}