From: Hillf Danton Subject: [patch 1/2] xen/arm: Free p2m entry if fail to add it to RB tree Date: Tue, 30 Apr 2019 13:31:46 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2639545842258205581==" Return-path: Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLLMz-0002Pi-8e for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 05:31:57 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" To: "xen-devel@lists.xenproject.org" Cc: "Stefano Stabellini " List-Id: xen-devel@lists.xenproject.org --===============2639545842258205581== Content-Type: multipart/alternative; boundary="_253F6C7A-9E51-4DD6-A5AD-72DE243D1479_" --_253F6C7A-9E51-4DD6-A5AD-72DE243D1479_ Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Release the newly allocated p2m entry if we detect a duplicate in the RB tr= ee. Cc: Stefano Stabellini Signed-off-by: Hillf Danton --- --- a/arch/arm/xen/p2m.c 2019-04-30 12:32:05.363768200 +0800 +++ b/arch/arm/xen/p2m.c 2019-04-30 12:41:29.774041800 +0800 @@ -156,6 +156,7 @@ bool __set_phys_to_machine_multi(unsigne rc =3D 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); -- --_253F6C7A-9E51-4DD6-A5AD-72DE243D1479_ Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"

Release the newly allocated p2m entry if we det= ect a duplicate in the RB tree.

 

Cc: Stefano Stabellini <sstabellini@kernel.org>

Signed-off-by: Hillf Danton <hdanton@sin= a.com>

---

<= p class=3DMsoNormal> 

--- a/arch/arm/xen/p2m.c 2019-04-30 12:32:0= 5.363768200 +0800

+++ b/a= rch/arm/xen/p2m.c=C2=A0=C2=A0=C2=A0 2019-04-30 12:41:29.774041800 +0800

@@ -156,6 +156,7 @@ bool __s= et_phys_to_machine_multi(unsigne

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D xen_add_phys_to_mach_e= ntry(p2m_entry);

=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc < 0) {

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 write_unlock_irqrestore(&p2m_lock, irqflags);

+=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kfree(p2m_entry);

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 return false;

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 write_unlo= ck_irqrestore(&p2m_lock, irqflags);

--=

 <= /span>

= --_253F6C7A-9E51-4DD6-A5AD-72DE243D1479_-- --===============2639545842258205581== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcKaHR0cHM6Ly9saXN0 cy54ZW5wcm9qZWN0Lm9yZy9tYWlsbWFuL2xpc3RpbmZvL3hlbi1kZXZlbA== --===============2639545842258205581==--