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 CID 1364766: Resource leaks
details: https://anonhg.NetBSD.org/src/rev/1a52f8518335
branches: trunk
changeset: 346849:1a52f8518335
user: knakahara <knakahara%NetBSD.org@localhost>
date: Fri Aug 05 06:58:55 2016 +0000
description:
fix CID 1364766: Resource leaks
diffstat:
usr.sbin/intrctl/intrctl_io.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diffs (59 lines):
diff -r fed3c4127d60 -r 1a52f8518335 usr.sbin/intrctl/intrctl_io.c
--- a/usr.sbin/intrctl/intrctl_io.c Fri Aug 05 06:54:22 2016 +0000
+++ b/usr.sbin/intrctl/intrctl_io.c Fri Aug 05 06:58:55 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intrctl_io.c,v 1.2 2016/08/03 08:28:09 knakahara Exp $ */
+/* $NetBSD: intrctl_io.c,v 1.3 2016/08/05 06:58:55 knakahara Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: intrctl_io.c,v 1.2 2016/08/03 08:28:09 knakahara Exp $");
+__RCSID("$NetBSD: intrctl_io.c,v 1.3 2016/08/05 06:58:55 knakahara Exp $");
#include <sys/sysctl.h>
#include <sys/intrio.h>
@@ -47,16 +47,16 @@
{
size_t buf_size;
int i, error;
- void *buf;
+ void *buf = NULL;
error = sysctlbyname("kern.intr.list", NULL, &buf_size, NULL, 0);
if (error < 0) {
- return NULL;
+ goto error;
}
buf = malloc(buf_size);
if (buf == NULL) {
- return NULL;
+ goto error;
}
for (i = 0; i < retry; i++) {
@@ -68,15 +68,16 @@
temp = realloc(buf, buf_size);
if (temp == NULL) {
- free(buf);
- return NULL;
+ goto error;
}
buf = temp;
} else {
- free(buf);
- return NULL;
+ goto error;
}
}
+error:
+ if (buf != NULL)
+ free(buf);
return NULL;
}
Home |
Main Index |
Thread Index |
Old Index