direct-io.hg

changeset 12179:de99c7f7aba4

[ACM] Don't use uninitialised struct value if hypercall fails.
From: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Oct 23 09:57:24 2006 +0100 (2006-10-23)
parents e3c70530cb28
children 63d1b02dad34
files tools/python/xen/lowlevel/acm/acm.c
line diff
     1.1 --- a/tools/python/xen/lowlevel/acm/acm.c	Fri Oct 20 11:00:08 2006 +0100
     1.2 +++ b/tools/python/xen/lowlevel/acm/acm.c	Mon Oct 23 09:57:24 2006 +0100
     1.3 @@ -147,9 +147,10 @@ static PyObject *getdecision(PyObject * 
     1.4  {
     1.5      char *arg1_name, *arg1, *arg2_name, *arg2, *decision = NULL;
     1.6      struct acm_getdecision getdecision;
     1.7 -    int xc_handle;
     1.8 +    int xc_handle, rc;
     1.9  
    1.10 -    if (!PyArg_ParseTuple(args, "ssss", &arg1_name, &arg1, &arg2_name, &arg2)) {
    1.11 +    if (!PyArg_ParseTuple(args, "ssss", &arg1_name,
    1.12 +                          &arg1, &arg2_name, &arg2)) {
    1.13          return NULL;
    1.14      }
    1.15  
    1.16 @@ -179,13 +180,17 @@ static PyObject *getdecision(PyObject * 
    1.17          getdecision.id2.ssidref = atol(arg2);
    1.18      }
    1.19  
    1.20 -    if (xc_acm_op(xc_handle, ACMOP_getdecision, &getdecision, sizeof(getdecision)) < 0) {
    1.21 +    rc = xc_acm_op(xc_handle, ACMOP_getdecision,
    1.22 +                   &getdecision, sizeof(getdecision));
    1.23 +
    1.24 +    xc_interface_close(xc_handle);
    1.25 +
    1.26 +    if (rc < 0) {
    1.27          if (errno == EACCES)
    1.28              PERROR("ACM operation failed.");
    1.29 +        return NULL;
    1.30      }
    1.31  
    1.32 -    xc_interface_close(xc_handle);
    1.33 -
    1.34      if (getdecision.acm_decision == ACM_ACCESS_PERMITTED)
    1.35          decision = "PERMITTED";
    1.36      else if (getdecision.acm_decision == ACM_ACCESS_DENIED)