diff options
Diffstat (limited to 'fs/namei.c')
-rw-r--r-- | fs/namei.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/namei.c b/fs/namei.c index 83e92bab79a6..33be51a2ddb7 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2906,7 +2906,11 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de | |||
2906 | return error; | 2906 | return error; |
2907 | 2907 | ||
2908 | mutex_lock(&inode->i_mutex); | 2908 | mutex_lock(&inode->i_mutex); |
2909 | error = dir->i_op->link(old_dentry, dir, new_dentry); | 2909 | /* Make sure we don't allow creating hardlink to an unlinked file */ |
2910 | if (inode->i_nlink == 0) | ||
2911 | error = -ENOENT; | ||
2912 | else | ||
2913 | error = dir->i_op->link(old_dentry, dir, new_dentry); | ||
2910 | mutex_unlock(&inode->i_mutex); | 2914 | mutex_unlock(&inode->i_mutex); |
2911 | if (!error) | 2915 | if (!error) |
2912 | fsnotify_link(dir, inode, new_dentry); | 2916 | fsnotify_link(dir, inode, new_dentry); |