diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-05-20 14:10:07 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-05-20 14:10:07 +0100 |
commit | 070cf3db9e23f3e16759ebfa9d17a79a6c9e532b (patch) | |
tree | 0127b4c8748287f678ac366d7c5841cfd8d1e72c /tools/xenstat | |
parent | 7c7e8d912627f343c3981e16edeabb6200047a40 (diff) | |
download | xen-070cf3db9e23f3e16759ebfa9d17a79a6c9e532b.tar.gz xen-070cf3db9e23f3e16759ebfa9d17a79a6c9e532b.tar.bz2 xen-070cf3db9e23f3e16759ebfa9d17a79a6c9e532b.zip |
xentop: fix NULL pointer dereference
On my system, I'm getting SIGSEGVs in xentop because
xenstat_node_domain() is returning NULL. Skip the loop if it does
rather than crashing.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/xenstat')
-rw-r--r-- | tools/xenstat/libxenstat/src/xenstat_linux.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c index c17423d3f3..1543fb21de 100644 --- a/tools/xenstat/libxenstat/src/xenstat_linux.c +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c @@ -292,20 +292,22 @@ int xenstat_collect_networks(xenstat_node * node) /* If the device parsed is network bridge and both tx & rx packets are zero, we are most */ /* likely using bonding so we alter the configuration for dom0 to have bridge stats */ - if ((strstr(iface, devBridge) != NULL) && (strstr(iface, devNoBridge) == NULL)) { - domain = xenstat_node_domain(node, 0); + if ((strstr(iface, devBridge) != NULL) && + (strstr(iface, devNoBridge) == NULL) && + ((domain = xenstat_node_domain(node, 0)) != NULL)) { for (i = 0; i < domain->num_networks; i++) { - if ((domain->networks[i].id == 0) && (domain->networks[i].tbytes == 0) - && (domain->networks[i].rbytes == 0)) { - domain->networks[i].tbytes = txBytes; - domain->networks[i].tpackets = txPackets; - domain->networks[i].terrs = txErrs; - domain->networks[i].tdrop = txDrops; - domain->networks[i].rbytes = rxBytes; - domain->networks[i].rpackets = rxPackets; - domain->networks[i].rerrs = rxErrs; - domain->networks[i].rdrop = rxDrops; - } + if ((domain->networks[i].id != 0) || + (domain->networks[i].tbytes != 0) || + (domain->networks[i].rbytes != 0)) + continue; + domain->networks[i].tbytes = txBytes; + domain->networks[i].tpackets = txPackets; + domain->networks[i].terrs = txErrs; + domain->networks[i].tdrop = txDrops; + domain->networks[i].rbytes = rxBytes; + domain->networks[i].rpackets = rxPackets; + domain->networks[i].rerrs = rxErrs; + domain->networks[i].rdrop = rxDrops; } } else /* Otherwise we need to preserve old behaviour */ |