Date: Mon, 14 Mar 2011 23:16:58 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r219651 - projects/ofed/head/sys/kern Message-ID: <201103142316.p2ENGwpm014572@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jeff Date: Mon Mar 14 23:16:57 2011 New Revision: 219651 URL: http://svn.freebsd.org/changeset/base/219651 Log: - Use SLIST_FOREACH_SAFE when removing OIDs which will be freed when not using a sysctl context. I don't know how we could've gone this long without running into this bug before. Modified: projects/ofed/head/sys/kern/kern_sysctl.c Modified: projects/ofed/head/sys/kern/kern_sysctl.c ============================================================================== --- projects/ofed/head/sys/kern/kern_sysctl.c Mon Mar 14 23:13:01 2011 (r219650) +++ projects/ofed/head/sys/kern/kern_sysctl.c Mon Mar 14 23:16:57 2011 (r219651) @@ -369,12 +369,12 @@ int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, int recurse) { - struct sysctl_oid *p; + struct sysctl_oid *p, *tmp; int error; error = ENOENT; SYSCTL_XLOCK(); - SLIST_FOREACH(p, SYSCTL_CHILDREN(parent), oid_link) { + SLIST_FOREACH_SAFE(p, SYSCTL_CHILDREN(parent), oid_link, tmp) { if (strcmp(p->oid_name, name) == 0) { error = sysctl_remove_oid_locked(p, del, recurse); break; @@ -389,7 +389,7 @@ sysctl_remove_name(struct sysctl_oid *pa static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) { - struct sysctl_oid *p; + struct sysctl_oid *p, *tmp; int error; SYSCTL_ASSERT_XLOCKED(); @@ -408,7 +408,8 @@ sysctl_remove_oid_locked(struct sysctl_o */ if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { if (oidp->oid_refcnt == 1) { - SLIST_FOREACH(p, SYSCTL_CHILDREN(oidp), oid_link) { + SLIST_FOREACH_SAFE(p, + SYSCTL_CHILDREN(oidp), oid_link, tmp) { if (!recurse) return (ENOTEMPTY); error = sysctl_remove_oid_locked(p, del,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103142316.p2ENGwpm014572>