Free mount credentials (mnt_cred) when freeing the mount struct

in failure cases to avoid leaking struct ucreds, and ultimately
leaking struct uidinfo references.
This commit is contained in:
tjr 2003-04-24 08:16:06 +00:00
parent 2ea336196e
commit d7f1e14b89

View File

@ -701,6 +701,7 @@ vfs_nmount(td, fsflags, fsoptions)
#ifdef MAC #ifdef MAC
mac_destroy_mount(mp); mac_destroy_mount(mp);
#endif #endif
crfree(mp->mnt_cred);
free(mp, M_MOUNT); free(mp, M_MOUNT);
} }
vrele(vp); vrele(vp);
@ -794,6 +795,7 @@ vfs_nmount(td, fsflags, fsoptions)
#ifdef MAC #ifdef MAC
mac_destroy_mount(mp); mac_destroy_mount(mp);
#endif #endif
crfree(mp->mnt_cred);
free(mp, M_MOUNT); free(mp, M_MOUNT);
vput(vp); vput(vp);
goto bad; goto bad;
@ -1064,6 +1066,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
#ifdef MAC #ifdef MAC
mac_destroy_mount(mp); mac_destroy_mount(mp);
#endif #endif
crfree(mp->mnt_cred);
free(mp, M_MOUNT); free(mp, M_MOUNT);
} }
vrele(vp); vrele(vp);
@ -1144,6 +1147,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
#ifdef MAC #ifdef MAC
mac_destroy_mount(mp); mac_destroy_mount(mp);
#endif #endif
crfree(mp->mnt_cred);
free(mp, M_MOUNT); free(mp, M_MOUNT);
vput(vp); vput(vp);
} }
@ -1570,6 +1574,7 @@ vfs_mountroot_try(char *mountfrom)
#ifdef MAC #ifdef MAC
mac_destroy_mount(mp); mac_destroy_mount(mp);
#endif #endif
crfree(mp->mnt_cred);
free(mp, M_MOUNT); free(mp, M_MOUNT);
} }
printf("Root mount failed: %d\n", error); printf("Root mount failed: %d\n", error);