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

[Xen-devel] [PATCH v2] tools/xenconsoled: Initialise pointers before trying to use them



This is a regression introduced by

"Switch from select() to poll() in xenconsoled's IO loop."
  hg c/s 26405:7359c3122c5d
  git cc5434c933153c4b8812d1df901f8915c22830a8

which results in reliable segfaults during VM power operations.

Switch to calloc(3) in an effort to avoid similar problems with changes in the
future.

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

---
Changes since v1:
 * Switch to calloc(3) instead of malloc, and remove redundant assignments

These segfaults are 100% reproducible in a XenServer system when rebooting a
PV domain. I am at a loss to explain why the OSS testing has not picked them up.

diff -r 94ece33caae2 -r b901a81f4f47 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -651,7 +651,7 @@ static struct domain *create_domain(int 
                return NULL;
        }
 
-       dom = (struct domain *)malloc(sizeof(struct domain));
+       dom = calloc(1, sizeof *dom);
        if (dom == NULL) {
                dolog(LOG_ERR, "Out of memory %s:%s():L%d",
                      __FILE__, __FUNCTION__, __LINE__);
@@ -672,21 +672,11 @@ static struct domain *create_domain(int 
        dom->slave_fd = -1;
        dom->log_fd = -1;
 
-       dom->is_dead = false;
-       dom->buffer.data = 0;
-       dom->buffer.consumed = 0;
-       dom->buffer.size = 0;
-       dom->buffer.capacity = 0;
-       dom->buffer.max_capacity = 0;
-       dom->event_count = 0;
        dom->next_period = ((long long)ts.tv_sec * 1000) + (ts.tv_nsec / 
1000000) + RATE_LIMIT_PERIOD;
-       dom->next = NULL;
 
        dom->ring_ref = -1;
        dom->local_port = -1;
        dom->remote_port = -1;
-       dom->interface = NULL;
-       dom->xce_handle = NULL;
 
        if (!watch_domain(dom, true))
                goto out;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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