aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 527119afb6a5..f3c5b278895a 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1698,8 +1698,11 @@ struct file *do_filp_open(int dfd, const char *pathname,
1698 if (error) 1698 if (error)
1699 return ERR_PTR(error); 1699 return ERR_PTR(error);
1700 error = path_walk(pathname, &nd); 1700 error = path_walk(pathname, &nd);
1701 if (error) 1701 if (error) {
1702 if (nd.root.mnt)
1703 path_put(&nd.root);
1702 return ERR_PTR(error); 1704 return ERR_PTR(error);
1705 }
1703 if (unlikely(!audit_dummy_context())) 1706 if (unlikely(!audit_dummy_context()))
1704 audit_inode(pathname, nd.path.dentry); 1707 audit_inode(pathname, nd.path.dentry);
1705 1708
@@ -1758,7 +1761,13 @@ do_last:
1758 goto exit; 1761 goto exit;
1759 } 1762 }
1760 filp = nameidata_to_filp(&nd, open_flag); 1763 filp = nameidata_to_filp(&nd, open_flag);
1764 if (IS_ERR(filp))
1765 ima_counts_put(&nd.path,
1766 acc_mode & (MAY_READ | MAY_WRITE |
1767 MAY_EXEC));
1761 mnt_drop_write(nd.path.mnt); 1768 mnt_drop_write(nd.path.mnt);
1769 if (nd.root.mnt)
1770 path_put(&nd.root);
1762 return filp; 1771 return filp;
1763 } 1772 }
1764 1773
@@ -1812,6 +1821,9 @@ ok:
1812 goto exit; 1821 goto exit;
1813 } 1822 }
1814 filp = nameidata_to_filp(&nd, open_flag); 1823 filp = nameidata_to_filp(&nd, open_flag);
1824 if (IS_ERR(filp))
1825 ima_counts_put(&nd.path,
1826 acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC));
1815 /* 1827 /*
1816 * It is now safe to drop the mnt write 1828 * It is now safe to drop the mnt write
1817 * because the filp has had a write taken 1829 * because the filp has had a write taken
@@ -1819,6 +1831,8 @@ ok:
1819 */ 1831 */
1820 if (will_write) 1832 if (will_write)
1821 mnt_drop_write(nd.path.mnt); 1833 mnt_drop_write(nd.path.mnt);
1834 if (nd.root.mnt)
1835 path_put(&nd.root);
1822 return filp; 1836 return filp;
1823 1837
1824exit_mutex_unlock: 1838exit_mutex_unlock:
@@ -1859,6 +1873,8 @@ do_link:
1859 * with "intent.open". 1873 * with "intent.open".
1860 */ 1874 */
1861 release_open_intent(&nd); 1875 release_open_intent(&nd);
1876 if (nd.root.mnt)
1877 path_put(&nd.root);
1862 return ERR_PTR(error); 1878 return ERR_PTR(error);
1863 } 1879 }
1864 nd.flags &= ~LOOKUP_PARENT; 1880 nd.flags &= ~LOOKUP_PARENT;