summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-01-23 03:45:22 +0000
committerpeter <peter@FreeBSD.org>1999-01-23 03:45:22 +0000
commit97e2cc89ef8a6c1f1a354ae29869c626cf8f617e (patch)
tree40a03e4f185235fc49861605760085cd0a6449a8 /sys/kern/kern_linker.c
parent260cf23ef1f394b8f4f29512be804afbd22761bf (diff)
downloadFreeBSD-src-97e2cc89ef8a6c1f1a354ae29869c626cf8f617e.zip
FreeBSD-src-97e2cc89ef8a6c1f1a354ae29869c626cf8f617e.tar.gz
Update userref handling after discussion with submitter of previous
patch. lf can't be dereferenced after the unload attempt, in case it was freed. Instead, decrement first and back it out if the unload failed. This should be relatively immune to races caused by the user since the userref count will be zero for the duration of the actual unloading and will stop further kldunload attempts. Submitted by: Ustimenko Semen <semen@iclub.nsu.ru>
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 97def9f..3f69c05 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: kern_linker.c,v 1.20 1999/01/19 16:26:32 peter Exp $
+ * $Id: kern_linker.c,v 1.21 1999/01/19 22:26:46 peter Exp $
*/
#include "opt_ddb.h"
@@ -680,14 +680,14 @@ kldunload(struct proc* p, struct kldunload_args* uap)
if (lf) {
KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs));
if (lf->userrefs == 0) {
- printf("linkerunload: attempt to unload file which was not loaded by user\n");
+ printf("linkerunload: attempt to unload file that was loaded by the kernel\n");
error = EBUSY;
goto out;
}
+ lf->userrefs--;
error = linker_file_unload(lf);
if (error)
- goto out;
- lf->userrefs--;
+ lf->userrefs++;
} else
error = ENOENT;
OpenPOWER on IntegriCloud