diff options
author | kib <kib@FreeBSD.org> | 2010-02-28 16:25:49 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2010-02-28 16:25:49 +0000 |
commit | f93a8fa5df25d78a9b746a05396cb56874e9115d (patch) | |
tree | ef34f9a348a27cb76f285b20cd1a1d67c07ffc33 /sys/net/if_tun.c | |
parent | 675be0dbc70bab58c8a57d7e399770557cb80a8d (diff) | |
download | FreeBSD-src-f93a8fa5df25d78a9b746a05396cb56874e9115d.zip FreeBSD-src-f93a8fa5df25d78a9b746a05396cb56874e9115d.tar.gz |
In both if_tun and if_tap:
Do not do additional dev_ref() on the newly created interface in the
if_clone create method [1]. This reference is not needed and never
removed, causing struct cdevpriv leakage. Remove the setting of
SI_CHEAPCLONE flag as well, since it is unused.
For dev_clone handlers, create cdevs with the call make_dev_credf(MAKEDEV_REF)
instead of calling make_dev() and then dev_ref(), to avoid a race.
Call drain_dev_clone_events() at the module unload time after dev_clone
handler is deinstalled.
Submitted by: Mikolaj Golub <to.my.trociny gmail com> [1]
MFC after: 1 week
Diffstat (limited to 'sys/net/if_tun.c')
-rw-r--r-- | sys/net/if_tun.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 37b5e70..1fa02ac 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -188,10 +188,6 @@ tun_clone_create(struct if_clone *ifc, int unit, caddr_t params) /* No preexisting struct cdev *, create one */ dev = make_dev(&tun_cdevsw, unit, UID_UUCP, GID_DIALER, 0600, "%s%d", ifc->ifc_name, unit); - if (dev != NULL) { - dev_ref(dev); - dev->si_flags |= SI_CHEAPCLONE; - } } tuncreate(ifc->ifc_name, dev); @@ -237,12 +233,8 @@ tunclone(void *arg, struct ucred *cred, char *name, int namelen, name = devname; } /* No preexisting struct cdev *, create one */ - *dev = make_dev(&tun_cdevsw, u, + *dev = make_dev_credf(MAKEDEV_REF, &tun_cdevsw, u, cred, UID_UUCP, GID_DIALER, 0600, "%s", name); - if (*dev != NULL) { - dev_ref(*dev); - (*dev)->si_flags |= SI_CHEAPCLONE; - } } if_clone_create(name, namelen, NULL); @@ -303,6 +295,7 @@ tunmodevent(module_t mod, int type, void *data) case MOD_UNLOAD: if_clone_detach(&tun_cloner); EVENTHANDLER_DEREGISTER(dev_clone, tag); + drain_dev_clone_events(); mtx_lock(&tunmtx); while ((tp = TAILQ_FIRST(&tunhead)) != NULL) { |