ia64/xen-unstable

changeset 4645:cc637433c0fd

bitkeeper revision 1.1373 (426a2bc8m7wX71OOkLtSOgNXcrObMA)

xc_domain.c:
Ensure ctxt is mlocked in xc_domain_getfullinfo.
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 23 11:04:40 2005 +0000 (2005-04-23)
parents c7f1dee0ac34
children 7317dcb7ef66
files tools/libxc/xc_domain.c
line diff
     1.1 --- a/tools/libxc/xc_domain.c	Sat Apr 23 10:53:18 2005 +0000
     1.2 +++ b/tools/libxc/xc_domain.c	Sat Apr 23 11:04:40 2005 +0000
     1.3 @@ -146,7 +146,7 @@ int xc_domain_getfullinfo(int xc_handle,
     1.4                            xc_domaininfo_t *info,
     1.5                            full_execution_context_t *ctxt)
     1.6  {
     1.7 -    int rc;
     1.8 +    int rc, errno_saved;
     1.9      dom0_op_t op;
    1.10  
    1.11      op.cmd = DOM0_GETDOMAININFO;
    1.12 @@ -154,12 +154,23 @@ int xc_domain_getfullinfo(int xc_handle,
    1.13      op.u.getdomaininfo.exec_domain = (u16)vcpu;
    1.14      op.u.getdomaininfo.ctxt = ctxt;
    1.15  
    1.16 +    if ( (ctxt != NULL) &&
    1.17 +         ((rc = mlock(ctxt, sizeof(*ctxt))) != 0) )
    1.18 +        return rc;
    1.19 +
    1.20      rc = do_dom0_op(xc_handle, &op);
    1.21  
    1.22 -    if ( info )
    1.23 +    if ( ctxt != NULL )
    1.24 +    {
    1.25 +        errno_saved = errno;
    1.26 +        (void)munlock(ctxt, sizeof(*ctxt));
    1.27 +        errno = errno_saved;
    1.28 +    }
    1.29 +
    1.30 +    if ( info != NULL )
    1.31          memcpy(info, &op.u.getdomaininfo, sizeof(*info));
    1.32  
    1.33 -    if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 )
    1.34 +    if ( ((u16)op.u.getdomaininfo.domain != domid) && (rc > 0) )
    1.35          return -ESRCH;
    1.36      else
    1.37          return rc;