summaryrefslogtreecommitdiffstats
path: root/cmd/zpool/zpool_main.c
diff options
context:
space:
mode:
authorTony Hutter <[email protected]>2017-12-06 11:43:07 -0800
committerBrian Behlendorf <[email protected]>2017-12-06 11:43:07 -0800
commit674b89342e43bd83659285d730b5b6a98f8b4b48 (patch)
treeb81a10f5efb8516580109d82930dba431a18c206 /cmd/zpool/zpool_main.c
parent1b2b0acab54ad4320e9fab9f46612fdb2a71cf87 (diff)
Fix segfault in zpool iostat when adding VDEVs
Fix a segfault when running 'zpool iostat -v 1' while adding a VDEV. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #6748 Closes #6872
Diffstat (limited to 'cmd/zpool/zpool_main.c')
-rw-r--r--cmd/zpool/zpool_main.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 440b29799..a44167a38 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -3648,7 +3648,7 @@ print_vdev_stats(zpool_handle_t *zhp, const char *name, nvlist_t *oldnv,
nvlist_t *newnv, iostat_cbdata_t *cb, int depth)
{
nvlist_t **oldchild, **newchild;
- uint_t c, children;
+ uint_t c, children, oldchildren;
vdev_stat_t *oldvs, *newvs, *calcvs;
vdev_stat_t zerovs = { 0 };
char *vname;
@@ -3760,9 +3760,13 @@ children:
&newchild, &children) != 0)
return (ret);
- if (oldnv && nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_CHILDREN,
- &oldchild, &c) != 0)
- return (ret);
+ if (oldnv) {
+ if (nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_CHILDREN,
+ &oldchild, &oldchildren) != 0)
+ return (ret);
+
+ children = MIN(oldchildren, children);
+ }
for (c = 0; c < children; c++) {
uint64_t ishole = B_FALSE, islog = B_FALSE;
@@ -3818,9 +3822,13 @@ children:
&newchild, &children) != 0)
return (ret);
- if (oldnv && nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_L2CACHE,
- &oldchild, &c) != 0)
- return (ret);
+ if (oldnv) {
+ if (nvlist_lookup_nvlist_array(oldnv, ZPOOL_CONFIG_L2CACHE,
+ &oldchild, &oldchildren) != 0)
+ return (ret);
+
+ children = MIN(oldchildren, children);
+ }
if (children > 0) {
if ((!(cb->cb_flags & IOS_ANYHISTO_M)) && !cb->cb_scripted &&