[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] Argo: don't obtain excess page references



commit cfbcfce494a1c1b1df618e3f06ec5b45352e5fe9
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Mar 6 10:17:36 2024 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Mar 6 10:17:36 2024 +0100

    Argo: don't obtain excess page references
    
    find_ring_mfn() already holds a page reference when trying to obtain a
    writable type reference. We shouldn't make assumptions on the general
    reference count limit being effectively "infinity". Obtain merely a type
    ref, re-using the general ref by only dropping the previously acquired
    one in the case of an error.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 xen/common/argo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/common/argo.c b/xen/common/argo.c
index 5dc5e45c7b..da3d3f325f 100644
--- a/xen/common/argo.c
+++ b/xen/common/argo.c
@@ -1425,7 +1425,7 @@ find_ring_mfn(struct domain *d, gfn_t gfn, mfn_t *mfn)
     switch ( p2mt )
     {
     case p2m_ram_rw:
-        if ( !get_page_and_type(page, d, PGT_writable_page) )
+        if ( !get_page_type(page, PGT_writable_page) )
             ret = -EINVAL;
         break;
 
@@ -1440,7 +1440,8 @@ find_ring_mfn(struct domain *d, gfn_t gfn, mfn_t *mfn)
         break;
     }
 
-    put_page(page);
+    if ( unlikely(ret) )
+        put_page(page);
 
     return ret;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.