diff options
author | kib <kib@FreeBSD.org> | 2007-03-29 08:21:09 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2007-03-29 08:21:09 +0000 |
commit | 96951962986768f0f216181e20ec59426f00d809 (patch) | |
tree | 3db7abb4567fa3ff03abcca2c9ecf0ff623d85dd | |
parent | 84d0794e0a57b20f5403f22876e11258ba7a7990 (diff) | |
download | FreeBSD-src-96951962986768f0f216181e20ec59426f00d809.zip FreeBSD-src-96951962986768f0f216181e20ec59426f00d809.tar.gz |
Extend rev. 1.210 to avoid dereference NULL mp in VFS_NEEDSGIANT and
VFS_ASSERT_GIANT. Stop using reserved namespace.
Reported and tested by: kris
Reviewed and enhanced by: tegge
MFC after: 1 week
-rw-r--r-- | sys/sys/mount.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/sys/mount.h b/sys/sys/mount.h index e225f20..772d721 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -573,15 +573,22 @@ vfs_statfs_t __vfs_statfs; extern int mpsafe_vfs; -#define VFS_NEEDSGIANT(MP) \ +#define VFS_NEEDSGIANT_(MP) \ (!mpsafe_vfs || ((MP) != NULL && ((MP)->mnt_kern_flag & MNTK_MPSAFE) == 0)) +#define VFS_NEEDSGIANT(MP) __extension__ \ +({ \ + struct mount *_mp; \ + _mp = (MP); \ + VFS_NEEDSGIANT_(_mp); \ +}) + #define VFS_LOCK_GIANT(MP) __extension__ \ ({ \ int _locked; \ - struct mount *_MP; \ - _MP = (MP); \ - if (VFS_NEEDSGIANT(_MP)) { \ + struct mount *_mp; \ + _mp = (MP); \ + if (VFS_NEEDSGIANT_(_mp)) { \ mtx_lock(&Giant); \ _locked = 1; \ } else \ @@ -591,7 +598,9 @@ extern int mpsafe_vfs; #define VFS_UNLOCK_GIANT(locked) if ((locked)) mtx_unlock(&Giant); #define VFS_ASSERT_GIANT(MP) do \ { \ - if (VFS_NEEDSGIANT((MP))) \ + struct mount *_mp; \ + _mp = (MP); \ + if (VFS_NEEDSGIANT_(_mp)) \ mtx_assert(&Giant, MA_OWNED); \ } while (0) |