Properly dispose of cfdata memory when unloading the tap(4) LKM.

This commit is contained in:
cube 2006-02-01 05:51:58 +00:00
parent 9f02c7bd62
commit 97047d48dd
2 changed files with 8 additions and 10 deletions
sys
lkm/net/tap
net

@ -1,4 +1,4 @@
/* $NetBSD: if_tap_lkm.c,v 1.3 2005/12/11 12:24:49 christos Exp $ */
/* $NetBSD: if_tap_lkm.c,v 1.4 2006/02/01 05:51:58 cube Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 The NetBSD Foundation.
@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap_lkm.c,v 1.3 2005/12/11 12:24:49 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap_lkm.c,v 1.4 2006/02/01 05:51:58 cube Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -78,6 +78,7 @@ static int tap_lkmunload(struct lkm_table *, int);
void tapattach(int);
int tapdetach(void);
int tap_clone_destroyer(struct device *);
SYSCTL_SETUP_PROTO(sysctl_tap_setup);
extern struct cfattach tap_ca;
@ -172,11 +173,8 @@ tap_lkmunload(struct lkm_table *lkmtp, int cmd)
for (i = 0; i < tap_cd.cd_ndevs; i++)
if (tap_cd.cd_devs[i] != NULL &&
(error = config_detach(tap_cd.cd_devs[i], 0)) != 0) {
aprint_error("%s: unable to detach instance\n",
((struct device *)tap_cd.cd_devs[i])->dv_xname);
(error = tap_clone_destroyer(tap_cd.cd_devs[i])) != 0)
return error;
}
sysctl_teardown(&tap_log);

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.11 2005/12/11 12:24:51 christos Exp $ */
/* $NetBSD: if_tap.c,v 1.12 2006/02/01 05:51:58 cube Exp $ */
/*
* Copyright (c) 2003, 2004 The NetBSD Foundation.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.11 2005/12/11 12:24:51 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.12 2006/02/01 05:51:58 cube Exp $");
#if defined(_KERNEL_OPT)
#include "bpfilter.h"
@ -222,7 +222,7 @@ struct if_clone tap_cloners = IF_CLONE_INITIALIZER("tap",
/* Helper functionis shared by the two cloning code paths */
static struct tap_softc * tap_clone_creator(int);
static int tap_clone_destroyer(struct device *);
int tap_clone_destroyer(struct device *);
void
tapattach(int n)
@ -614,7 +614,7 @@ tap_clone_destroy(struct ifnet *ifp)
return tap_clone_destroyer((struct device *)ifp->if_softc);
}
static int
int
tap_clone_destroyer(struct device *dev)
{
struct cfdata *cf = dev->dv_cfdata;