Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/altq Fix error branches to avoid leaks, noted by maxv@.
details: https://anonhg.NetBSD.org/src/rev/82eea4a13e26
branches: trunk
changeset: 331642:82eea4a13e26
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 18 03:14:12 2014 +0000
description:
Fix error branches to avoid leaks, noted by maxv@.
diffstat:
sys/altq/altq_jobs.c | 27 +++++++++++++++++++--------
1 files changed, 19 insertions(+), 8 deletions(-)
diffs (77 lines):
diff -r fcdf5756b653 -r 82eea4a13e26 sys/altq/altq_jobs.c
--- a/sys/altq/altq_jobs.c Mon Aug 18 02:43:27 2014 +0000
+++ b/sys/altq/altq_jobs.c Mon Aug 18 03:14:12 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: altq_jobs.c,v 1.6 2010/04/09 19:32:45 plunky Exp $ */
+/* $NetBSD: altq_jobs.c,v 1.7 2014/08/18 03:14:12 riastradh Exp $ */
/* $KAME: altq_jobs.c,v 1.11 2005/04/13 03:44:25 suz Exp $ */
/*
* Copyright (c) 2001, the Rector and Board of Visitors of the
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_jobs.c,v 1.6 2010/04/09 19:32:45 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_jobs.c,v 1.7 2014/08/18 03:14:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_altq.h"
@@ -1158,7 +1158,7 @@
error = update_error(jif);
if (!error)
- return (NULL);
+ goto fail;
prop_control = (upper_bound*upper_bound*min_share)
/(max_prod*(max_avg_pkt_size << 2));
@@ -1252,6 +1252,9 @@
}
}
return result;
+
+fail: free(result, M_DEVBUF);
+ return NULL;
}
/*
@@ -1284,19 +1287,19 @@
result = malloc((jif->jif_maxpri+1)*sizeof(int64_t), M_DEVBUF, M_WAITOK);
if (result == NULL)
- return NULL;
+ goto fail0;
c = malloc((jif->jif_maxpri+1)*sizeof(u_int64_t), M_DEVBUF, M_WAITOK);
if (c == NULL)
- return NULL;
+ goto fail1;
n = malloc((jif->jif_maxpri+1)*sizeof(u_int64_t), M_DEVBUF, M_WAITOK);
if (n == NULL)
- return NULL;
+ goto fail2;
k = malloc((jif->jif_maxpri+1)*sizeof(u_int64_t), M_DEVBUF, M_WAITOK);
if (k == NULL)
- return NULL;
+ goto fail3;
available = malloc((jif->jif_maxpri+1)*sizeof(int64_t), M_DEVBUF, M_WAITOK);
if (available == NULL)
- return NULL;
+ goto fail4;
for (i = 0; i <= jif->jif_maxpri; i++)
result[i] = 0;
@@ -1525,6 +1528,14 @@
free(available, M_DEVBUF);
return (result);
+
+fail5: __unused
+ free(available, M_DEVBUF);
+fail4: free(k, M_DEVBUF);
+fail3: free(n, M_DEVBUF);
+fail2: free(c, M_DEVBUF);
+fail1: free(result, M_DEVBUF);
+fail0: return NULL;
}
/*
Home |
Main Index |
Thread Index |
Old Index