Date: Sun, 26 Mar 2006 19:17:43 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 94079 for review Message-ID: <200603261917.k2QJHhLc028686@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94079 Change 94079 by jhb@jhb_zion on 2006/03/26 19:17:37 Simple Giant pushdown. Affected files ... .. //depot/projects/smpng/sys/kern/kern_linker.c#42 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_linker.c#42 (text+ko) ==== @@ -758,13 +758,11 @@ td->td_retval[0] = -1; - mtx_lock(&Giant); - if ((error = securelevel_gt(td->td_ucred, 0)) != 0) - goto out; + return (error); if ((error = suser(td)) != 0) - goto out; + return (error); pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); if ((error = copyinstr(uap->file, pathname, MAXPATHLEN, NULL)) != 0) @@ -782,16 +780,16 @@ kldname = NULL; modname = pathname; } + + mtx_lock(&Giant); error = linker_load_module(kldname, modname, NULL, NULL, &lf); - if (error) - goto out; - - lf->userrefs++; - td->td_retval[0] = lf->id; + if (error == 0) { + lf->userrefs++; + td->td_retval[0] = lf->id; + } + mtx_unlock(&Giant); out: - if (pathname) - free(pathname, M_TEMP); - mtx_unlock(&Giant); + free(pathname, M_TEMP); return (error); } @@ -804,14 +802,13 @@ linker_file_t lf; int error = 0; - mtx_lock(&Giant); - if ((error = securelevel_gt(td->td_ucred, 0)) != 0) - goto out; + return (error); if ((error = suser(td)) != 0) - goto out; + return (error); + mtx_lock(&Giant); lf = linker_find_file_by_id(fileid); if (lf) { KLD_DPF(FILE, ("kldunload: lf->userrefs=%d\n", lf->userrefs)); @@ -822,15 +819,14 @@ printf("kldunload: attempt to unload file that was" " loaded by the kernel\n"); error = EBUSY; - goto out; + } else { + lf->userrefs--; + error = linker_file_unload(lf, flags); + if (error) + lf->userrefs++; } - lf->userrefs--; - error = linker_file_unload(lf, flags); - if (error) - lf->userrefs++; } else error = ENOENT; -out: mtx_unlock(&Giant); return (error); } @@ -875,7 +871,6 @@ return (error); #endif - mtx_lock(&Giant); td->td_retval[0] = -1; pathname = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); @@ -883,15 +878,15 @@ goto out; filename = linker_basename(pathname); + mtx_lock(&Giant); lf = linker_find_file_by_name(filename); + mtx_unlock(&Giant); if (lf) td->td_retval[0] = lf->id; else error = ENOENT; out: - if (pathname) - free(pathname, M_TEMP); - mtx_unlock(&Giant); + free(pathname, M_TEMP); return (error); } @@ -1041,22 +1036,20 @@ return (error); #endif - mtx_lock(&Giant); - if ((error = copyin(uap->data, &lookup, sizeof(lookup))) != 0) - goto out; + return (error); if (lookup.version != sizeof(lookup) || - uap->cmd != KLDSYM_LOOKUP) { - error = EINVAL; - goto out; - } + uap->cmd != KLDSYM_LOOKUP) + return (EINVAL); symstr = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); if ((error = copyinstr(lookup.symname, symstr, MAXPATHLEN, NULL)) != 0) goto out; + mtx_lock(&Giant); if (uap->fileid != 0) { lf = linker_find_file_by_id(uap->fileid); if (lf == NULL) { error = ENOENT; + mtx_unlock(&Giant); goto out; } if (LINKER_LOOKUP_SYMBOL(lf, symstr, &sym) == 0 && @@ -1082,10 +1075,9 @@ if (lf == NULL) error = ENOENT; } + mtx_unlock(&Giant); out: - if (symstr) - free(symstr, M_TEMP); - mtx_unlock(&Giant); + free(symstr, M_TEMP); return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603261917.k2QJHhLc028686>