Module Name: src
Committed By: riastradh
Date: Mon Aug 18 04:16:59 UTC 2014
Modified Files:
src/sys/dev/qbus: if_qe.c
Log Message:
Avoid leak in error branch, noted by maxv@, compile-tested for vax.
To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/qbus/if_qe.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/qbus/if_qe.c
diff -u src/sys/dev/qbus/if_qe.c:1.72 src/sys/dev/qbus/if_qe.c:1.73
--- src/sys/dev/qbus/if_qe.c:1.72 Fri Oct 25 15:42:50 2013
+++ src/sys/dev/qbus/if_qe.c Mon Aug 18 04:16:59 2014
@@ -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 @@ qematch(device_t parent, cfdata_t cf, vo
#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 @@ qematch(device_t parent, cfdata_t cf, vo
*/
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 @@ qematch(device_t parent, cfdata_t cf, vo
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;
}
/*