Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/intrctl fix free() on unitialized value for list -c...



details:   https://anonhg.NetBSD.org/src/rev/decdfd5c6aa0
branches:  trunk
changeset: 320095:decdfd5c6aa0
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Jun 22 22:50:53 2018 +0000

description:
fix free() on unitialized value for list -c when there are no
assigned interrupts

diffstat:

 usr.sbin/intrctl/intrctl.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r c0170ac150ec -r decdfd5c6aa0 usr.sbin/intrctl/intrctl.c
--- a/usr.sbin/intrctl/intrctl.c        Fri Jun 22 20:48:43 2018 +0000
+++ b/usr.sbin/intrctl/intrctl.c        Fri Jun 22 22:50:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intrctl.c,v 1.7 2016/11/02 11:03:33 ryo Exp $  */
+/*     $NetBSD: intrctl.c,v 1.8 2018/06/22 22:50:53 jdolecek Exp $     */
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: intrctl.c,v 1.7 2016/11/02 11:03:33 ryo Exp $");
+__RCSID("$NetBSD: intrctl.c,v 1.8 2018/06/22 22:50:53 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -184,7 +184,7 @@
                printf("%-*s ", (int)intridlen, illine->ill_intrid);
                if (compact) {
                        uint64_t total = 0;
-                       char *affinity, *oaffinity = NULL;
+                       char *affinity = NULL, *oaffinity = NULL;
                        for (i = 0; i < ncpus; i++) {
                                illc = &illine->ill_cpu[i];
                                total += illc->illc_count;
@@ -200,7 +200,8 @@
                        }
                        printf("%20" PRIu64 " ", total);
                        printf("%5s ", affinity ? affinity : "none");
-                       free(affinity);
+                       if (affinity)
+                               free(affinity);
                } else {
                        for (i = 0; i < ncpus; i++) {
                                illc = &illine->ill_cpu[i];



Home | Main Index | Thread Index | Old Index