From: Andrew Deason Date: Wed, 17 Apr 2013 06:33:07 +0000 (-0500) Subject: LINUX: Avoid duplicate mntget in afs_linux_raw_open X-Git-Tag: openafs-stable-1_8_0pre1~1217 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=5ccbbda19f11e7027300409c46715155f439424a;hp=e019429d4548348c6ab8674305d985feee040476 LINUX: Avoid duplicate mntget in afs_linux_raw_open In the unlikely event that our afs_dentry_open call fails with cache_creds, we call afs_dentry_open again with the current creds as a fallback. However, we call mntget on afs_cacheMnt for each call. So if we actually hit the second call, we'll have added 2 refs to afs_cacheMnt, but we only actually opened one file, causing a slight overcount on afs_cacheMnt refs. To avoid this, just call mntget once, before any of the dentry_open-related calls. Change-Id: I7ec3e8c193dd7782ab629fb5d7615d83f8385b6c Reviewed-on: http://gerrit.openafs.org/9791 Tested-by: BuildBot Reviewed-by: Marc Dionne Reviewed-by: Derrick Brashear --- diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index eacffca..b48bf1a 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -54,13 +54,17 @@ afs_linux_raw_open(afs_dcache_id_t *ainode) tip = dp->d_inode; tip->i_flags |= S_NOATIME; /* Disable updating access times. */ + /* note that if this is ever changed to recover from errors, we will need + * to put this reference back */ + mntget(afs_cacheMnt); + #if defined(STRUCT_TASK_STRUCT_HAS_CRED) /* Use stashed credentials - prevent selinux/apparmor problems */ - filp = afs_dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, cache_creds); + filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, cache_creds); if (IS_ERR(filp)) - filp = afs_dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred()); + filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, current_cred()); #else - filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR); + filp = dentry_open(dp, afs_cacheMnt, O_RDWR); #endif if (IS_ERR(filp)) osi_Panic("Can't open file: %d\n", (int) PTR_ERR(filp));