Skip to content

Commit d0ff934

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS fixes from Al Viro: "Several fixes + obvious cleanup (you've missed a couple of open-coded can_lookup() back then)" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: snd_pcm_link(): fix a leak... use can_lookup() instead of direct checks of ->i_op->lookup move exit_task_namespaces() outside of exit_notify() fput: task_work_add() can fail if the caller has passed exit_task_work() ncpfs: fix rmdir returns Device or resource busy
2 parents d58c6ff + dd6c5cd commit d0ff934

File tree

5 files changed

+15
-23
lines changed

5 files changed

+15
-23
lines changed

fs/file_table.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,18 @@ void fput(struct file *file)
306306
{
307307
if (atomic_long_dec_and_test(&file->f_count)) {
308308
struct task_struct *task = current;
309+
unsigned long flags;
310+
309311
file_sb_list_del(file);
310-
if (unlikely(in_interrupt() || task->flags & PF_KTHREAD)) {
311-
unsigned long flags;
312-
spin_lock_irqsave(&delayed_fput_lock, flags);
313-
list_add(&file->f_u.fu_list, &delayed_fput_list);
314-
schedule_work(&delayed_fput_work);
315-
spin_unlock_irqrestore(&delayed_fput_lock, flags);
316-
return;
312+
if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
313+
init_task_work(&file->f_u.fu_rcuhead, ____fput);
314+
if (!task_work_add(task, &file->f_u.fu_rcuhead, true))
315+
return;
317316
}
318-
init_task_work(&file->f_u.fu_rcuhead, ____fput);
319-
task_work_add(task, &file->f_u.fu_rcuhead, true);
317+
spin_lock_irqsave(&delayed_fput_lock, flags);
318+
list_add(&file->f_u.fu_list, &delayed_fput_list);
319+
schedule_work(&delayed_fput_work);
320+
spin_unlock_irqrestore(&delayed_fput_lock, flags);
320321
}
321322
}
322323

fs/namei.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@ static int path_lookupat(int dfd, const char *name,
19761976
err = complete_walk(nd);
19771977

19781978
if (!err && nd->flags & LOOKUP_DIRECTORY) {
1979-
if (!nd->inode->i_op->lookup) {
1979+
if (!can_lookup(nd->inode)) {
19801980
path_put(&nd->path);
19811981
err = -ENOTDIR;
19821982
}
@@ -2850,7 +2850,7 @@ static int do_last(struct nameidata *nd, struct path *path,
28502850
if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
28512851
goto out;
28522852
error = -ENOTDIR;
2853-
if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup)
2853+
if ((nd->flags & LOOKUP_DIRECTORY) && !can_lookup(nd->inode))
28542854
goto out;
28552855
audit_inode(name, nd->path.dentry, 0);
28562856
finish_open:

fs/ncpfs/dir.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,15 +1029,6 @@ static int ncp_rmdir(struct inode *dir, struct dentry *dentry)
10291029
DPRINTK("ncp_rmdir: removing %s/%s\n",
10301030
dentry->d_parent->d_name.name, dentry->d_name.name);
10311031

1032-
/*
1033-
* fail with EBUSY if there are still references to this
1034-
* directory.
1035-
*/
1036-
dentry_unhash(dentry);
1037-
error = -EBUSY;
1038-
if (!d_unhashed(dentry))
1039-
goto out;
1040-
10411032
len = sizeof(__name);
10421033
error = ncp_io2vol(server, __name, &len, dentry->d_name.name,
10431034
dentry->d_name.len, !ncp_preserve_case(dir));

kernel/exit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
649649
* jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
650650
*/
651651
forget_original_parent(tsk);
652-
exit_task_namespaces(tsk);
653652

654653
write_lock_irq(&tasklist_lock);
655654
if (group_dead)
@@ -795,6 +794,7 @@ void do_exit(long code)
795794
exit_shm(tsk);
796795
exit_files(tsk);
797796
exit_fs(tsk);
797+
exit_task_namespaces(tsk);
798798
exit_task_work(tsk);
799799
check_stack_usage();
800800
exit_thread();

sound/core/pcm_native.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
16491649
}
16501650
if (!snd_pcm_stream_linked(substream)) {
16511651
substream->group = group;
1652+
group = NULL;
16521653
spin_lock_init(&substream->group->lock);
16531654
INIT_LIST_HEAD(&substream->group->substreams);
16541655
list_add_tail(&substream->link_list, &substream->group->substreams);
@@ -1663,8 +1664,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
16631664
_nolock:
16641665
snd_card_unref(substream1->pcm->card);
16651666
fput_light(file, fput_needed);
1666-
if (res < 0)
1667-
kfree(group);
1667+
kfree(group);
16681668
return res;
16691669
}
16701670

0 commit comments

Comments
 (0)