kernel: Fix potential refcount leak in su check
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / namei.c
index 36d4b29459ecb52a713c1cc3565e426a36e43c77..67d8ee787f0135acdaf4b509519e693858dec01a 100644 (file)
@@ -2012,8 +2012,10 @@ static int path_lookupat(int dfd, const char *name,
        if (!err) {
                struct super_block *sb = nd->inode->i_sb;
                if (sb->s_flags & MS_RDONLY) {
        if (!err) {
                struct super_block *sb = nd->inode->i_sb;
                if (sb->s_flags & MS_RDONLY) {
-                       if (d_is_su(nd->path.dentry) && !su_visible())
+                       if (d_is_su(nd->path.dentry) && !su_visible()) {
+                               path_put(&nd->path);
                                err = -ENOENT;
                                err = -ENOENT;
+                       }
                }
        }
 
                }
        }