From 425f1cc2218af96d81dbec092155d436d6037d2c Mon Sep 17 00:00:00 2001 From: Hillf Danton Date: Tue, 30 Apr 2019 11:25:00 -0700 Subject: xen/arm: Free p2m entry if fail to add it to RB tree Release the newly allocated p2m entry if we detect a duplicate in the RB tree. Signed-off-by: Hillf Danton Signed-off-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- arch/arm/xen/p2m.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/arm') diff --git a/arch/arm/xen/p2m.c b/arch/arm/xen/p2m.c index e70a49fc8dcd..d3f632c88890 100644 --- a/arch/arm/xen/p2m.c +++ b/arch/arm/xen/p2m.c @@ -156,6 +156,7 @@ bool __set_phys_to_machine_multi(unsigned long pfn, rc = xen_add_phys_to_mach_entry(p2m_entry); if (rc < 0) { write_unlock_irqrestore(&p2m_lock, irqflags); + kfree(p2m_entry); return false; } write_unlock_irqrestore(&p2m_lock, irqflags); -- cgit v1.2.3 From fe846979d30576107aa9910e1820fec3c20e62d7 Mon Sep 17 00:00:00 2001 From: Hillf Danton Date: Tue, 30 Apr 2019 11:26:08 -0700 Subject: xen/arm: Use p2m entry with lock protection A new local variable is introduced for accessing p2m entry with lock protection. Signed-off-by: Hillf Danton Signed-off-by: Stefano Stabellini Reviewed-by: Stefano Stabellini --- arch/arm/xen/p2m.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/xen/p2m.c b/arch/arm/xen/p2m.c index d3f632c88890..da2a7044a124 100644 --- a/arch/arm/xen/p2m.c +++ b/arch/arm/xen/p2m.c @@ -70,8 +70,9 @@ unsigned long __pfn_to_mfn(unsigned long pfn) entry = rb_entry(n, struct xen_p2m_entry, rbnode_phys); if (entry->pfn <= pfn && entry->pfn + entry->nr_pages > pfn) { + unsigned long mfn = entry->mfn + (pfn - entry->pfn); read_unlock_irqrestore(&p2m_lock, irqflags); - return entry->mfn + (pfn - entry->pfn); + return mfn; } if (pfn < entry->pfn) n = n->rb_left; -- cgit v1.2.3