Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/qbus Avoid leak in error branch, noted by maxv@, com...
details: https://anonhg.NetBSD.org/src/rev/84c1841a0a26
branches: trunk
changeset: 331645:84c1841a0a26
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 18 04:16:59 2014 +0000
description:
Avoid leak in error branch, noted by maxv@, compile-tested for vax.
diffstat:
sys/dev/qbus/if_qe.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diffs (57 lines):
diff -r 2a4044fde228 -r 84c1841a0a26 sys/dev/qbus/if_qe.c
--- a/sys/dev/qbus/if_qe.c Mon Aug 18 03:59:27 2014 +0000
+++ b/sys/dev/qbus/if_qe.c Mon Aug 18 04:16:59 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_qe.c,v 1.72 2013/10/25 15:42:50 martin Exp $ */
+/* $NetBSD: if_qe.c,v 1.73 2014/08/18 04:16:59 riastradh Exp $ */
/*
* Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_qe.c,v 1.72 2013/10/25 15:42:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_qe.c,v 1.73 2014/08/18 04:16:59 riastradh Exp $");
#include "opt_inet.h"
@@ -142,7 +142,7 @@
#define PROBESIZE 4096
struct qe_ring *ring;
struct qe_ring *rp;
- int error;
+ int error, match;
ring = malloc(PROBESIZE, M_TEMP, M_WAITOK|M_ZERO);
memset(sc, 0, sizeof(*sc));
@@ -161,8 +161,10 @@
*/
ui.ui_size = PROBESIZE;
ui.ui_vaddr = (void *)&ring[0];
- if ((error = uballoc(uh, &ui, UBA_CANTWAIT)))
- return 0;
+ if ((error = uballoc(uh, &ui, UBA_CANTWAIT))) {
+ match = 0;
+ goto out0;
+ }
/*
* Init a simple "fake" receive and transmit descriptor that
@@ -192,12 +194,14 @@
QE_WCSR(QE_CSR_XMTH, HIWORD(rp));
DELAY(10000);
+ match = 1;
+
/*
* All done with the bus resources.
*/
ubfree(uh, &ui);
- free(ring, M_TEMP);
- return 1;
+out0: free(ring, M_TEMP);
+ return match;
}
/*
Home |
Main Index |
Thread Index |
Old Index