Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcsh Fix always free. It call, if memory was allo...
details: https://anonhg.NetBSD.org/src/rev/829044daff09
branches: trunk
changeset: 755914:829044daff09
user: kiyohara <kiyohara%NetBSD.org@localhost>
date: Mon Jun 28 11:18:44 2010 +0000
description:
Fix always free. It call, if memory was allocated.
diffstat:
sys/arch/hpcsh/hpcsh/bus_space.c | 17 ++++++++++-------
sys/arch/hpcsh/include/bus.h | 5 ++++-
2 files changed, 14 insertions(+), 8 deletions(-)
diffs (66 lines):
diff -r cb8ba4768e46 -r 829044daff09 sys/arch/hpcsh/hpcsh/bus_space.c
--- a/sys/arch/hpcsh/hpcsh/bus_space.c Mon Jun 28 09:46:27 2010 +0000
+++ b/sys/arch/hpcsh/hpcsh/bus_space.c Mon Jun 28 11:18:44 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.15 2008/04/28 20:23:22 martin Exp $ */
+/* $NetBSD: bus_space.c,v 1.16 2010/06/28 11:18:44 kiyohara Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.15 2008/04/28 20:23:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.16 2010/06/28 11:18:44 kiyohara Exp $");
#include "debug_hpcsh.h"
@@ -138,12 +138,14 @@
bus_space_create(struct hpcsh_bus_space *hbs, const char *name,
bus_addr_t addr, bus_size_t size)
{
- if (hbs == NULL)
- hbs = malloc(sizeof(*hbs), M_DEVBUF, M_NOWAIT);
+
+ if (hbs == NULL) {
+ hbs = malloc(sizeof(*hbs), M_DEVBUF, M_NOWAIT | M_ZERO);
+ hbs->hbs_flags = HBS_FLAGS_ALLOCATED;
+ } else
+ memset(hbs, 0, sizeof(*hbs));
KASSERT(hbs);
- memset(hbs, 0, sizeof(*hbs));
-
/* set default method */
*hbs = __default_bus_space;
hbs->hbs_cookie = hbs;
@@ -172,7 +174,8 @@
if (ex != NULL)
extent_destroy(ex);
- free(t, M_DEVBUF);
+ if (hbs->hbs_flags & HBS_FLAGS_ALLOCATED)
+ free(hbs, M_DEVBUF);
}
/* default bus_space tag */
diff -r cb8ba4768e46 -r 829044daff09 sys/arch/hpcsh/include/bus.h
--- a/sys/arch/hpcsh/include/bus.h Mon Jun 28 09:46:27 2010 +0000
+++ b/sys/arch/hpcsh/include/bus.h Mon Jun 28 11:18:44 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.18 2009/12/05 16:29:12 pooka Exp $ */
+/* $NetBSD: bus.h,v 1.19 2010/06/28 11:18:44 kiyohara Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -119,6 +119,9 @@
/* cookie */
void *hbs_cookie;
+ int hbs_flags;
+#define HBS_FLAGS_ALLOCATED (1 < 0)
+
/* mapping/unmapping */
int (*hbs_map)(void *, bus_addr_t, bus_size_t,
int, bus_space_handle_t *);
Home |
Main Index |
Thread Index |
Old Index