]> granicus.if.org Git - sysstat/commitdiff
sadf: SVG: Fix coredump problem when --dev option used
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 26 May 2018 15:47:18 +0000 (17:47 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 26 May 2018 15:47:18 +0000 (17:47 +0200)
Function svg_print_disk_stats() should allocate only the necessary
number of slots when a list of devices has been entered on the
command line with option "--dev=".

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
svg_stats.c

index b6f899425cdbf76aacf0470d4e495a0619138be0..798894110f39966dd7e643f31fd532361dad1b2b 100644 (file)
@@ -2084,6 +2084,16 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                for (i = 0; i < a->nr[curr]; i++) {
                        sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
 
+                       /* Get device name */
+                       item_name = get_sa_devname(sdc->major, sdc->minor, flags);
+
+                       if (dlst_dev_idx) {
+                               /* A list of devices has been entered on the command line */
+                               if (!search_sa_dlist(st_dev_list, dlst_dev_idx, item_name))
+                                       /* Device not found */
+                                       continue;
+                       }
+
                        /* Look for corresponding graph */
                        for (k = 0; k < svg_p->nr_max; k++) {
                                if ((sdc->major == *(spmax + k * 9 + 8)) &&
@@ -2107,15 +2117,6 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                        pos = k * 9;
                        unregistered = outsize + pos + 8;
 
-                       j = check_disk_reg(a, curr, !curr, i);
-                       if (j < 0) {
-                               /* This is a newly registered interface. Previous stats are zero */
-                               sdp = &sdpzero;
-                       }
-                       else {
-                               sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
-                       }
-
                        /*
                         * If current device was marked as previously unregistered,
                         * then set restart variable to TRUE so that the graph will be
@@ -2132,6 +2133,15 @@ __print_funct_t svg_print_disk_stats(struct activity *a, int curr, int action, s
                                *(spmin + pos + 8) = sdc->minor;
                        }
 
+                       j = check_disk_reg(a, curr, !curr, i);
+                       if (j < 0) {
+                               /* This is a newly registered interface. Previous stats are zero */
+                               sdp = &sdpzero;
+                       }
+                       else {
+                               sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
+                       }
+
                        /* Check for min/max values */
                        save_extrema(local_types_nr, (void *) sdc, (void *) sdp,
                                     itv, spmin + pos, spmax + pos, g_fields);