[PATCH 19/21] Unionfs: Actually catch bad use of unionfs_mnt{get,put}

Josef 'Jeff' Sipek
2007-05-24T00:39:30Z

fs/unionfs/union.h | 34 +++++++---------------------------
1 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 5376b76..335d579 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -459,38 +459,18 @@ static inline void unlock_dir(struct dentry *dir)
static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
int bindex)
{
- struct vfsmount *mnt;
+ BUG_ON(!dentry || bindex < 0);

- if (!dentry) {
- if (bindex < 0)
- return NULL;
- BUG_ON(bindex < 0);
- }
- mnt = unionfs_lower_mnt_idx(dentry, bindex);
- if (!mnt) {
- if (bindex < 0)
- return NULL;
- BUG_ON(mnt && bindex < 0);
- }
- mnt = mntget(mnt);
- return mnt;
+ return mntget(unionfs_lower_mnt_idx(dentry, bindex));
}

static inline void unionfs_mntput(struct dentry *dentry, int bindex)
{
- struct vfsmount *mnt;
+ if (!dentry)
+ return;

- if (!dentry) {
- if (bindex < 0)
- return;
- BUG_ON(dentry && bindex < 0);
- }
- mnt = unionfs_lower_mnt_idx(dentry, bindex);
- if (!mnt) {
- if (bindex < 0)
- return;
- BUG_ON(mnt && bindex < 0);
- }
- mntput(mnt);
+ BUG_ON(bindex < 0);
+
+ mntput(unionfs_lower_mnt_idx(dentry, bindex));
}
#endif /* not _UNION_H_ */
--
1.5.2.rc1.165.gaf9b