From: Richard Weinberger Date: Fri, 27 Feb 2015 21:56:28 +0000 (+0100) Subject: hostfs: hostfs_file_open: Fix a fd leak in hostfs_file_open X-Git-Tag: v4.1-rc1~121^2~24 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=af9556586a906106453ff7df8bcacf795b2b7d0a;p=linux.git hostfs: hostfs_file_open: Fix a fd leak in hostfs_file_open In case of a race between to callers of hostfs_file_open() it can happen that a file describtor is leaked. Signed-off-by: Richard Weinberger --- diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 104d58d2c78c..112ba5aa0848 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -329,6 +329,7 @@ static int hostfs_file_open(struct inode *ino, struct file *file) /* somebody else had handled it first? */ if ((mode & HOSTFS_I(ino)->mode) == mode) { mutex_unlock(&HOSTFS_I(ino)->open_mutex); + close_file(&fd); return 0; } if ((mode | HOSTFS_I(ino)->mode) != mode) {